Place specific image in html page when specific name is typed.

Posted on 16th Feb 2014 by admin

Hello,

Fairly new to PHP and was curious if someone might know how to solve a fairly simple request.

I am currently passing the name of an end user (who types their name in a form field) to a URL which is then passed along and placed into an html page to personalize the page for them to print. Is there a way that I could use PHP to use a specific image for a specific name typed in the field?

Example would be:

Name typed in field: Bob
Picture used: Baseball

OR

Name typed in field: Alison:
Picture used: Cat

Below is some of the coder snippets I am using.



Here is the code from the form that the end user types in their name:

<form id="form1" name="form1" method="post" action="name_of_user.php">

<label>Gallery Name:<br />
<input type="text" name="name" id="name" />
</label>
<br />
<label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
</label>
</form>

Here is the code that receives the post from above file:
<?php

$Name = Trim(stripslashes($_POST['Name']));

// redirect to success page
if ($success){
print "<meta http-equiv="refresh" content="0;URL=path to file/comp_pass_exhibitor.php?name=$Name">";
}
else{
print "<meta http-equiv="refresh" content="0;URL=path to file/comp_pass_exhibitor.php?name=$Name">";
}
?>


________Below is code from the html page I want personalised_______

Here is the bit of code that places the name in the html page:
<p><strong>
<span style="text-transform:uppercase;"><?php echo $_GET['name']; ?></span>

some text that doesn't change</strong> </p>

Here is the bit of code for the image on the html page:

<td>
<img src=" What would go here " width="140" height="109" align="left">
</td>



Any help would be appreciated

Other forums