Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Novice needs help.. Undefined Variables...

Status
Not open for further replies.

Wullie

Programmer
Mar 17, 2001
3,674
0
36
GB
Hi all,

I am a total novice when it comes to PHP so please excuse me if this is simple..

I keep on getting undefined variable messages but the script still works..

I have the following form to send an sms to me through an email address. The sms is sent


<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML><HEAD><TITLE>Send me an SMS message.</TITLE>
<META http-equiv=Content-Type content=&quot;text/html; charset=iso-8859-1&quot;>
<STYLE type=text/css>.button {
FONT-SIZE: 12px; BORDER-LEFT-COLOR: #306898; BORDER-BOTTOM-COLOR: #306898; WIDTH: 60px; COLOR: #336699; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #336699; FONT-FAMILY: Geneva, Arial, Helvetica, san-serif; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; HEIGHT: 20px; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-COLOR: #306898; BORDER-BOTTOM-STYLE: solid
}
.forms {
BORDER-RIGHT: #3868a0 1px ridge; BORDER-TOP: #336699 1px ridge; FONT-SIZE: 12px; BORDER-LEFT: #3868a0 1px ridge; COLOR: #336699; BORDER-BOTTOM: #3868a0 1px ridge; FONT-FAMILY: Geneva, Arial, Helvetica, san-serif; BACKGROUND-COLOR: #ffffff
}
</STYLE>

<SCRIPT language=JavaScript><!--
if ((navigator.appVersion.indexOf(&quot;Mac&quot;) != -1) && (navigator.appVersion.indexOf(&quot;MSIE&quot;) == -1)) {document.write(&quot;<link rel=stylesheet href=\&quot;/css/test.css\&quot; type=\&quot;text/css\&quot;>&quot;); }else {document.write(&quot;<link rel=stylesheet href=\&quot;/css/test.css\&quot; type=\&quot;text/css\&quot;>&quot;); }function goB(){h=window.name.split(&quot;_&quot;);h[0]=parseInt(h[0])-1;window.name=h.join(&quot;_&quot;);history.back();}function goF(){h=window.name.split(&quot;_&quot;);h[0]=parseInt(h[0])+1;window.name=h.join(&quot;_&quot;);history.forward();}function goL(s){h=window.name.split(&quot;_&quot;);if(parseInt(h[0])<parseInt(h[1])){h[1]=h[0];}h[0]=parseInt(h[0])+1;h[1]=parseInt(h[1])+1;window.name=h.join(&quot;_&quot;);location.href=&quot;/u/&quot;+s;}function initcharsleft() {charsleft(document.forms[&quot;frm&quot;].text);}function charsleft(feld) {var anz = feld.value.length;if (anz> 87 ) {feld.value = feld.value.substring(0,160);frei = 0;} else {frei = 87 -anz;}document.forms[&quot;frm&quot;].num.value = frei;}//-->// -->
</SCRIPT>

<META content=&quot;MSHTML 5.50.4522.1800&quot; name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<TABLE cellSpacing=0 cellPadding=0 width=445 border=0>
<TBODY>
<TR>
<TD width=88 height=210 valign=&quot;top&quot; align=&quot;right&quot;><font color=&quot;#336699&quot;><b><br>
<br>
<font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Name:<br>
Message:</font> </b></font></TD>
<TD width=11></TD>
<TD vAlign=top width=285> 
<FORM name=frm onsubmit=&quot;return goL('')&quot; action=sendsms.php
method=post>
<INPUT type=hidden value=Sms name=page>
<INPUT type=hidden
value=send_sms name=action>
<INPUT type=hidden value=Robouk name=nickname>
<INPUT class=forms name=email>
<BR>
<TEXTAREA class=forms onkeypress=charsleft(this); onkeydown=charsleft(this); onblur=charsleft(this); onkeyup=charsleft(this); onfocus=charsleft(this); name=msg rows=3 wrap=VIRTUAL onchange=charsleft(this);></TEXTAREA>
<BR>
<font color=&quot;#336699&quot; size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>Characters
Left </font>
<INPUT

onfocus=this.blur size=4 value=87 name=num class=&quot;forms&quot;>
<br>
      
<INPUT class=button type=submit value=&quot;Send &quot; border=0 name=submit height=&quot;5&quot; width=&quot;10&quot;>
</FORM>
</TD>
<TD width=61></TD>
</TR>
</TBODY>
</TABLE>
</BODY></HTML>

********IN THE SENDSMS.PHP I HAVE THE FOLLOWING***********

<?php
if($message == &quot;2&quot;){
echo &quot;Sorry!, you have already submitted the maximum times allowed&quot;;

}else{

$num = $sentmessage + 1;
setcookie(&quot;sentmessage&quot;,&quot;$num&quot;,time()+86400); //set the cookie

$to = &quot;me@email.com&quot;;
$subject = &quot;$email , $msg&quot;;

$mailheaders = &quot;From: $email \n&quot;;
$mailheaders .= &quot;Reply-To: $email\n\n&quot;;

mail($to, $subject, $msg, $mailheaders);

?>
<html><head><title>I have recieved your message</title></head><body>

Thank you, i have recieved your message.<br><br>
I will contact you as soon as I can.
</body>
</html>
<?

}//end submitted


?>

Any ideas how to fix this?

Thanks in advance.. Wullie

 
Hi,

Make sure you have defined all of your variables before you use them. i.e don't do a comparison (if $var == 'var') unless $var has been previously defined - even if it's predefined to a blank string!!

Hope this helps {Greenser}
 
Looks like $sentmessage has not been set prior to $num=($sentmessage +1); ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top