472,348 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,348 software developers and data experts.

Notice: Undefined index:

Can anyone help me,
i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is:

Notice: Undefined index: FriendName in D:\Yan\Over_8\SendEmail.php on line 4, Notice: Undefined index: FriendEmail in D:\Yan\Over_8\SendEmail.php on line 5, Notice: Undefined index: Name in D:\Yan\Over_8\SendEmail.php on line 6, Notice: Undefined index: Email in D:\Yan\Over_8\SendEmail.php on line 7, Notice: Undefined index: emailtext in D:\Yan\Over_8\SendEmail.php on line 8.

I have changed in the php.ini file the smtp setting to divert the emails to the my exchange server as this server is seprate and also added the server to the relay list. I can send email from this script still but only externally. I have also tried adding this: error_reporting(E_ALL ^ E_NOTICE); .into the script to hide the errors. It does hide them but the script does not work sending email externally.
My script is:
[PHP]
<title>Recommend This Site</title>

<?php
$FriendName = $_POST['FriendName'];
$FriendEmail = $_POST['FriendEmail'];
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$emailtext = $_POST['emailtext'];
$string = $_SERVER['QUERY_STRING'];

?>
<html><head>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body bgcolor="#999999">
<?php
if (!$FriendEmail) {
?>
<br>
<form name="form1" onsubmit="MM_validateForm('Name','','R','Email','' ,'RisEmail','FriendName','','R','FriendEmail','',' RisEmail');return document.MM_returnValue" action="" method="POST">
<div align="center">
<table width="427" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="63" align="right" valign="top"> </td>
<td width="5"><font face="Verdana" size="2"> </font></td>
<td width="138"><font face="Verdana" size="2" color="#FFFFFF">Name: </font> </td>
<td width="216"> <font face="Verdana" size="2" color="#FFFFFF">E-mail:</font></td>
</tr>
<tr>
<td align="right" valign="top">
<font face="Verdana" size="2" color="#FFFFFF">You:</font></td>
<td> </td>
<td>
<font face="Verdana">
<input type="text" name="Name" size="18"><font size="2"> </font></font>
</td>
<td>
<font face="Verdana">
<input type="text" name="Email" size="21"><font size="2"> </font></font>
</td>
</tr>
<tr>
<td align="right" valign="top">
<font face="Verdana" size="2" color="#FFFFFF">Friend:</font></td>
<td> </td>
<td>
<font face="Verdana">
<input type="text" name="FriendName" size="18"><font size="2"> </font>
</font>
</td>
<td>
<font face="Verdana">
<input type="text" name="FriendEmail" size="21"><font size="2"> </font>
</font>
</td>
</tr>
<tr>
<td align="right" valign="top">
<font face="Verdana" size="2" color="#FFFFFF">Message:</font></td>
<td> </td>
<td colspan="2">
<font face="Verdana">
<textarea name="emailtext" cols="38" rows="6" style="font-family: Trebuchet MS; font-size: 10pt">
I found this great website and I believe you would be interested in it.
Here is the link to that Website: http://www.number1yan.co.uk
</textarea><font size="2"> </font></font>
</td>
</tr>
<tr>
<td align="right"> </td>
<td><font face="Verdana" size="2"> </font> </td>
<td>
<font face="Verdana">
<input type="submit" value="Send Message" name="Submit"><font size="2"> </font>
</font>
</td>
<td> </td>
</tr>
</table>
</div>
</form>
<?php
}
else {
if ($FriendEmail) { mail( $FriendEmail, "Message from $Name", "$FriendName, \n\n".$emailtext ."\n\n$Name", "From: $Email");

}


echo "<center><br><br><font color=FFFFFF><font face=Verdana size=2>Thank you <font color=000000>$Name</font><font color=000000>.
<p><br>
<font color=FFFFFF> The email has been sent to <font color=000000>$FriendName</font><font color=000000>.
<p><br>
<br><a href='javascript:window.close();'>Close this window</a></font><p>
<font face=Verdana size=2></a></font></p>";
}
?>
<p> </p>
</body>
</html>
[/PHP]

Can anyone help please, my email is: removed@readthefaq.com.
Thanks
Apr 28 '07 #1
3 5337
code green
1,726 Expert 1GB
Your POST array contains the names of your HTML enitities. You have named the textboxes Email, Name etc. But you are trying to read FriendEmail, FriendName. And please use tags when submitting code.
Apr 28 '07 #2
Your POST array contains the names of your HTML enitities. You have named the textboxes Email, Name etc. But you are trying to read FriendEmail, FriendName. And please use tags when submitting code.
So how will i fix this problem?
Apr 28 '07 #3
pbmods
5,821 Expert 4TB
So how will i fix this problem?
Easy. Just enclose your code in PHP BBCode tags as described in the guidelines box to the right of the input when posting your code.

Oh. How to fix the problem in your code.

[PHP]
else {
if ($FriendEmail) { mail( $FriendEmail, "Message from $Name", "$FriendName, \n\n".$emailtext ."\n\n$Name", "From: $Email");

} // <-- Should this curly brace be here?


echo "<center><br><br><font color=FFFFFF><font face=Verdana size=2>Thank you <font color=000000>$Name</font><font color=000000>.
[/PHP]
Apr 28 '07 #4

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

Similar topics

6
by: jsgoodrich | last post by:
I am looking for some help if anyone can lend a hand. I have a simple php website that displays a table from my mysql database. To prep for my...
3
by: sickboy | last post by:
$channels=$_GET; if (empty($channels)) { $channels='blank'; } changechannels($channels); $theatre=$_GET; if (empty($theatre)) { $theatre='splash'; }...
1
by: francsutherland | last post by:
Notice: Undefined index: send in D:\Domains\workingdata.co.uk\wwwroot\contact_text.php on line 7 Hi, I've started getting this error in the...
10
by: FutureShock | last post by:
I have since recently turned up my error reporting on a production site to E_ALL to ensure I am using 'best practices' when writing out code. So...
11
by: stealthmode666 | last post by:
New to .php so need script help. I want to know how to stop this being displayed when I click submit. Notice: Undefined index: homeowner in...
4
by: complearn | last post by:
Do you know why I got these errors for status_bar.php in some webhost, but work perfectly on other webhost? Whats wrong? here are the codes...
3
by: razvanel442 | last post by:
Hi all i am new here! I take a look on forum but i don't found a the answer for my problem ok this is my problem: Line47:$user = $_GET;...
2
by: norwichchris | last post by:
hi, I am having serious trouble with my PHP Postcard script. The error message i get is: Notice: Undefined index: Notice: Undefined variable ...
2
by: nyrzs | last post by:
"Notice: Undefined index: prod_rep in F:\xampp\htdocs\isys\products\process.php on line 153 Notice: Undefined variable: prod_id in...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.