PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
onion2k
Jedi Mod
Posts: 5263 Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com
Post
by onion2k » Mon Apr 14, 2008 9:31 am
At a guess I'd say register_globals are switched off on the paid host. That means you can't access variables with $name, you have to explicitly use $_GET['name'] or $_POST['name'].
onion2k
Jedi Mod
Posts: 5263 Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com
Post
by onion2k » Mon Apr 14, 2008 9:55 am
You can't just stick an array variable into the middle of a string like that. Either use {} or escape out of the string..
Code: Select all
<?php
echo "Hello {$_GET['name']}!, How are you doing?";
//or
echo "Hello ".$_GET['name']."!, How are you doing?";
?>
Personally, I use the second way.
PS. Your form is using POST, so you need to use $_POST['name'].
akjackson1
Forum Newbie
Posts: 18 Joined: Mon Apr 14, 2008 9:08 am
Post
by akjackson1 » Mon Apr 14, 2008 10:06 am
Thanks so much it worked!
akjackson1
Forum Newbie
Posts: 18 Joined: Mon Apr 14, 2008 9:08 am
Post
by akjackson1 » Mon Apr 14, 2008 12:43 pm
I have a contact form that thanks the person by name and is supposed to send the information to a email addess, however I never get an email! It works when I make it just send the form and then go to a thank you page but then I can't thank than by name.
Here is what I have:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Message sent successfully</title>
<meta http-equiv="refresh" content="4; url=http://www.truth-for-youth.com/">
<link rel="stylesheet" type="text/css"href="main.css" />
<body>
<table width="309" border="0" align="center">
<tr>
<td><div align="center" class="Title2">
Thank You <?php
echo "".$_POST['name']."";
?>
</div>
<p align="center" class="style1">Your message was sent successfully!</p>
<p align="center" class="SmallText">If you are not automatically redirected in a few seconds, <a href="http://www.truth-foryouth.com/">click here</a> to proceed.</p>
<p class="style4"> </p></td>
</tr>
</table>
<span class="style2">
</span>
<?php
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$message = $_POST['message'] ;
mail( "akjackson1@gmail.com", "Contact Form", "Name: ". $name . "\r\n\r\n". "Email: " . $email . "\r\n\r\n" . "Message: ". $message . "\r\n\r\n". "Mailing List: ". $mailinglist, "From: $email" );
?>
</body>
</html>
The first part thanks the person and the bottom php part is supposed to send it.