Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/271529-help-notice-undefined-variable/
Share on other sites

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;

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>

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 by octa

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.

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.

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?

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.

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....

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 by jcbones
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.