By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 2,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

PHP undefined variable Email

P: 2
Hi everyone, Im a php newbie jejeej .

Im getting the following error undefined variable at line 19 , I verified the php.ini and I dont know what else I can do. Im working on IIS with windows xp/2000.
If someone can help , please!!

HTML



<body bgcolor="#000066">
<form action="mail.php" method="post">
<table width="740" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="740" height="330" background="contactenos.jpg"><div align="right">Nombre:
<input type="text" name="name" >
&nbsp;<br/>
Email:
<input type="text" name="email">
&nbsp;<br/>
Comentarios : &nbsp;&nbsp;&nbsp;<br/>
<textarea name="message" cols="40" rows="5" ></textarea>
&nbsp;<br/>
<input name="submit" type="submit" value="Enviar">
&nbsp; </div></td>
<td>&nbsp;</td>
</tr>
</table>
<br/>
</form>



mail.php



<?php

//variables (change these)


$youremail = "nante1181@hotmail.com";
// your email address

$subject = "test form";
// the subject of the email

$thankyou = "thankyou.php";
// thank you page

// don't change anything else

if($email == ""){
?>
<body bgcolor="#000066" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif">No introdujo
Email. Por favor vuelva a atras.<br/>
<?php
}elseif($name == ""){
?>
No Introdujo un nombre. Por favor vuelva a atras.<br/>
<?php
}elseif($message == ""){
?>
No Introdujo un mensaje. Por favor vuelva a atras.<br/>
<?php
}else{

$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";

mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
?>
</font></div>
<meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
<?php
}
?>


thanks for your help
Jan 12 '07 #1
Share this Question
Share on Google+
2 Replies


P: 2
the error is on if($email=="") it seems the php file its not recognizing the html variable
Jan 12 '07 #2

10K+
P: 13,264
the error is on if($email=="") it seems the php file its not recognizing the html variable

//variables (change these)

In
[PHP]$youremail = "nante1181@hotmail.com";
// your email address

$subject = "test form";
// the subject of the email

$thankyou = "thankyou.php";
// thank you page

// don't change anything else

if($email == ""){
?>
[/PHP]

You define and initialize the variables
$youremail, $subject and $thankyou
but did not initiaze $email variable which you go on to try to use in the line
[PHP]if($email == "
[/PHP]
the idea is you must declare variables before you can use them.
PHP will not recognize variables declared inHTML
Jan 12 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.