A simple PHP question...

EarnVoice

Regular Member
Joined
Jun 5, 2020
Messages
387
Reaction score
228
Hi guys,
I have no knowledge about php so I'm stuck even though the problem is easy..
I want to change text using url. For example
abc.com/mylink?=[text]
when I change [text] some text and images of the content will change accordingly.
thank you in advance my friends.
 
Pass the query string like following:
Code:
mysite.com/mylink.php?text=sometext

In your php file, you accept the parameter like following:

Code:
<?php
$text = isset($_GET['text'])? $_GET['text'] : "";
echo $text;
?>
Now, obviously this is the basic functionality; and unless you define what you are trying to do in a better way; this is all we could give you.
 
Pass the query string like following:
Code:
mysite.com/mylink.php?text=sometext

In your php file, you accept the parameter like following:

Code:
<?php
$text = isset($_GET['text'])? $_GET['text'] : "";
echo $text;
?>
Now, obviously this is the basic functionality; and unless you define what you are trying to do in a better way; this is all we could give you.
Thank you very much.
In the content I have:
My link is really ugly so I want to change [text]
And also I have image link:
Images/[text].png
How can I replace them?
I guess the code is <?php echo $text; ?> everywhere?
 
Thank you very much.
In the content I have:
My link is really ugly so I want to change [text]
And also I have image link:
Images/[text].png
How can I replace them?
I guess the code is <?php echo $text; ?> everywhere?
For that you will need .htaccess redirect (considering you use apache server). Your .htaccess file might look like this:

Code:
Options +FollowSymLinks
RewriteEngine On
#replace /image/index.php with your sub folder. If you are on main folder (e.g. site root)
# then replace /image/index.php with /index.php
RewriteRule ^([A-Za-z0-9_-]+).png /image/index.php?text=$1 [QSA,L]

Your PHP file would look like this:
Code:
<?php 
$text = isset($_GET['text'])? $_GET['text'] : "";

echo $text;

Here's how the folder structure looks for me:
Capture.PNG
 
For that you will need .htaccess redirect (considering you use apache server). Your .htaccess file might look like this:

Code:
Options +FollowSymLinks
RewriteEngine On
#replace /image/index.php with your sub folder. If you are on main folder (e.g. site root)
# then replace /image/index.php with /index.php
RewriteRule ^([A-Za-z0-9_-]+).png /image/index.php?text=$1 [QSA,L]

Your PHP file would look like this:
Code:
<?php
$text = isset($_GET['text'])? $_GET['text'] : "";

echo $text;

Here's how the folder structure looks for me:
View attachment 138692
sorry I don't get it
Here is the code I use, but the image link doesn't work
In head tag
Code:
<?php
$card = isset($_GET['card'])? $_GET['card'] : "";
?>
In content, alt text working but img src doesn't which means the image doesn't show.
Code:
<div class="card"><a href="javascript:active();"><img src="/images/<?php echo $card; ?>.png" alt="<?php echo $card; ?> Card"
 
Back
Top