octa Posted December 3, 2012 Share Posted December 3, 2012 Notice: Undefined variable: subject in C:\wampp\www\itvideohelps\send_contact.php on line 5 Notice: Undefined variable: detail in C:\wampp\www\itvideohelps\send_contact.php on line 8 Notice: Undefined variable: customer_mail in C:\wampp\www\itvideohelps\send_contact.php on line 12 Notice: Undefined variable: name in C:\wampp\www\itvideohelps\send_contact.php on line 15 We've recived your contact information on this line script <html> <?php // Contact subject $subject ="$subject"; // Details $message="$detail"; // Mail of sender $mail_from="$customer_mail"; // From $header="from: $name <$mail_from>"; // Enter your email address $to ='octa@localhost'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?> </html> using localhost , i have install ArGoSoft mail server , and I did email settings outlook expresss help , thanks Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/ Share on other sites More sharing options...
MDCode Posted December 3, 2012 Share Posted December 3, 2012 You're calling a variable by a variable that isn't defined. Of course it's going to give an undefined notice. Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397149 Share on other sites More sharing options...
floridaflatlander Posted December 3, 2012 Share Posted December 3, 2012 This is common, where do you define subject & detail at? You could do something like if (isset($detail) {$message = "$detail";} which looks better or up at the beginning of the file put something like $subject = $detail = FALSE; Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397151 Share on other sites More sharing options...
octa Posted December 3, 2012 Author Share Posted December 3, 2012 You're calling a variable by a variable that isn't defined. Of course it's going to give an undefined notice. how fix the problemn ? Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397153 Share on other sites More sharing options...
MDCode Posted December 3, 2012 Share Posted December 3, 2012 how fix the problemn ? Well, we need to see your form and your full page of code if you haven't posted it already. I think what you might be looking for is $_POST['subject'], $_POST['detail'], etc. Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397155 Share on other sites More sharing options...
octa Posted December 3, 2012 Author Share Posted December 3, 2012 Well, we need to see your form and your full page of code if you haven't posted it already. I think what you might be looking for is $_POST['subject'], $_POST['detail'], etc. full page of contact.php? Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397157 Share on other sites More sharing options...
MDCode Posted December 3, 2012 Share Posted December 3, 2012 If that is where your form and processing code is located yes. Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397158 Share on other sites More sharing options...
octa Posted December 3, 2012 Author Share Posted December 3, 2012 If that is where your form and processing code is located yes. this is contact.php <table width="400" border="0" align="center" cellpadding="3" cellspacing="1"> <tr> <td><strong>Contact Form </strong></td> </tr> </table> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="send_contact.php"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td width="16%">Subject</td> <td width="2%">:</td> <td width="82%"><input name="subject" type="text" id="subject" size="50"></td> </tr> <tr> <td>Detail</td> <td>:</td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td> </tr> <tr> <td>Name</td> <td>:</td> <td><input name="name" type="text" id="name" size="50"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="customer_mail" type="text" id="customer_mail" size="50"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td> </tr> </table> </form> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397160 Share on other sites More sharing options...
MDCode Posted December 3, 2012 Share Posted December 3, 2012 (edited) Yes, you are looking for $_POST['subject'] not $subject. Change all those ($subject, $detail, $customer_mail). Edited December 3, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397161 Share on other sites More sharing options...
octa Posted December 3, 2012 Author Share Posted December 3, 2012 (edited) Yes, you are looking for $_POST['subject'] not $subject. Change all those ($subject, $detail, $customer_mail). modified.. i see error Notice: Undefined index: mail_from in C:\wampp\www\itvideohelps\send_contact.php on line 15 We've recived your contact information <?php // Contact subject $subject =$_POST['subject'] ; // Details $message=$_POST['detail']; // Mail of sender $mail_from=$_POST['customer_mail']; // From $header=$_POST['mail_from']; THIS LINE 15 // Enter your email address $to ='octa@localhost'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?> Edited December 3, 2012 by octa Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397162 Share on other sites More sharing options...
MDCode Posted December 3, 2012 Share Posted December 3, 2012 Remove the quotations like you did with $_POST['subject']; Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397164 Share on other sites More sharing options...
octa Posted December 3, 2012 Author Share Posted December 3, 2012 Remove the quotations like you did with $_POST['subject']; yes, but I have a problem, line 15 $header=$_POST['mail_from']; Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397165 Share on other sites More sharing options...
Jessica Posted December 3, 2012 Share Posted December 3, 2012 It's telling you exactly what is wrong. In the $_POST array, there is NO index called 'mail_from'. This is your code: $mail_from=$_POST['customer_mail']; $header=$_POST['mail_from']; Do you understand how variables work? What an array is? How forms work? The problem you have right now is basic logic. Would you expect this to work? $foo = 'bar'; echo $myArr['foo']; Cause that's what you're doing. Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397166 Share on other sites More sharing options...
PFMaBiSmAd Posted December 3, 2012 Share Posted December 3, 2012 Only part of line 15 should have been changed. The code you found/learned... is over 10years out of date, it also isn't validating anything so I hope you are not going to put this on a live web server where spammers can find it and send their email through your mail server. Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397168 Share on other sites More sharing options...
octa Posted December 3, 2012 Author Share Posted December 3, 2012 yes , written this $mail_from=$_POST['customer_mail']; $header=$_POST['mail_from']; and continue this error Notice: Undefined index: mail_from in C:\wampp\www\itvideohelps\send_contact.php on line 15 how do I resolve this problemp? Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397169 Share on other sites More sharing options...
Jessica Posted December 3, 2012 Share Posted December 3, 2012 Read it and rephrase it in English. What do those two lines say? Look at my example: $foo = 'bar'; echo $myArr['foo']; In english this says. Assign the string 'bar' to a variable $foo. Echo the value of the array $myArr at the key of string 'foo'. Will that do anything useful? Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397170 Share on other sites More sharing options...
MDCode Posted December 3, 2012 Share Posted December 3, 2012 It's telling you exactly what is wrong. In the $_POST array, there is NO index called 'mail_from'. The problem you have right now is basic logic. Would you expect this to work? Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397171 Share on other sites More sharing options...
octa Posted December 3, 2012 Author Share Posted December 3, 2012 i'm not american , I know some English but using google translate , i don't understand expression , please write the code to attach Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397172 Share on other sites More sharing options...
Jessica Posted December 3, 2012 Share Posted December 3, 2012 (edited) OMG then use your own language. Also, it's not just Americans who speak English. The UK, Canada, Australia and NZ, the nordic countries speak it well, South Africa, etc. Edited December 3, 2012 by Jessica Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397174 Share on other sites More sharing options...
octa Posted December 3, 2012 Author Share Posted December 3, 2012 (edited) OMG then use your own language. Also, it's not just Americans who speak English. The UK, Canada, Australia and NZ, the nordic countries speak it well, South Africa, etc. Romania no speak englishh Edited December 3, 2012 by octa Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397177 Share on other sites More sharing options...
octa Posted December 3, 2012 Author Share Posted December 3, 2012 OMG then use your own language. Also, it's not just Americans who speak English. The UK, Canada, Australia and NZ, the nordic countries speak it well, South Africa, etc. Romaniaa no speak englishh Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397178 Share on other sites More sharing options...
Jessica Posted December 3, 2012 Share Posted December 3, 2012 Then find a Romanian forum. Don't come to a forum where you can't communicate and ask us to write code for you. That is rude. The rules of this forum is we help you debug and fix your code. Not write it for you. If you need very detailed explanations and can't speak English, maybe don't go to a forum that is primarily English. Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397180 Share on other sites More sharing options...
octa Posted December 3, 2012 Author Share Posted December 3, 2012 Then find a Romanian forum. Don't come to a forum where you can't communicate and ask us to write code for you. That is rude. The rules of this forum is we help you debug and fix your code. Not write it for you. If you need very detailed explanations and can't speak English, maybe don't go to a forum that is primarily English. it was not hard to write a few letters, because I was helpful .. finally thanksss.... Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397186 Share on other sites More sharing options...
jcbones Posted December 3, 2012 Share Posted December 3, 2012 (edited) Here you go: $mail_from=$_POST['customer_mail']; //$header=$_POST['mail_from']; //no good 'mail_from' doesn't exist in the $_POST array, but it does exist as a variable. $header = $mail_from; //good. Edited December 3, 2012 by jcbones Quote Link to comment https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/#findComment-1397238 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.