Forum Moderators: coopster

Message Too Old, No Replies

Parse error: syntax error, unexpected T ELSE in E:\CustomerData\websp

         

ake15

2:30 pm on Mar 28, 2008 (gmt 0)

10+ Year Member



im having an error..obviously...i dont know how to fix this any help from anybody..please...heres the code

<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];
?>
<form name="form1" method="post"
action="<?php echo $me;?>">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><font face="Arial, Helvetica, sans-serif">Name:</font></td>
<td><input type="text" name="Name"></td>
</tr></br>
<tr>
<td><font face="Arial, Helvetica, sans-serif">E-mail:</font></td>
<td><input type="text" name="e-mail"></td>
</tr></br>
<tr>
<td valign="top"><font face="Arial, Helvetica, sans-serif">Phone:</font></td>
<td><input name="Phone" type="text" value=""></td>
</tr></br>
<tr>
<td><font face="Arial, Helvetica, sans-serif">Fax:</font></td>
<td><input type="text" name="Fax"></td>
</tr></br>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit"
value="Send"></td>
</tr></br>
</table>
</form>
}
<p>
<?php
else {
error_reporting(0);
$recipient = 'aaron@example.com';
$from = stripslashes($_POST['Name']);
$e-mail = stripslashes($_POST['E-mail']);
$phone = stripslashes($_POST['Phone']);
$fax = stripslashes($_POST['Fax']);
if (mail($recipient, $name, $e-mail, $phone, $fax))
echo nl2br("<b>Message Sent:</b>
To: $recipient
Name: $name
E-mail: $e-mail
Phone: $phone
Fax: $fax
$msg");
else
echo "Message failed to send";
}
?>

all help is greatly appreciated

[edited by: jatar_k at 2:37 pm (utc) on Mar. 28, 2008]
[edit reason] examplified email [/edit]

jatar_k

2:38 pm on Mar 28, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you're missing a closing brace before the else

<?php
else {

should be

<?php
} else {

ake15

2:52 pm on Mar 28, 2008 (gmt 0)

10+ Year Member



now it says

Parse error: syntax error, unexpected '=' in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 107

jatar_k

3:03 pm on Mar 28, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



there aren't even close to 107 lines so can you show me which line that is, as well as a couple lines before

bilenkyj

3:12 pm on Mar 28, 2008 (gmt 0)

10+ Year Member



i would stick in a hidden field in your form trigger and give it a value of go.

The you could have an second if statement (if $_post[trigger] =="go") then set the email variables and emails the send the email then have the last else on the end

form

if
if
else

bilenkyj

3:17 pm on Mar 28, 2008 (gmt 0)

10+ Year Member



<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];
?>
<form name="form1" method="post"
action="<?php echo $me;?>">
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td><font face="Arial, Helvetica, sans-serif">Name:</font></td>
<td><input type="text" name="Name"></td>
</tr></br>
<tr>
<td><font face="Arial, Helvetica, sans-serif">E-mail:</font></td>
<td><input type="text" name="e-mail"></td>
<td><input type="hidden" name="trigger" value="go"></td>
</tr></br>
<tr>
<td valign="top"><font face="Arial, Helvetica, sans-serif">Phone:</font></td>
<td><input name="Phone" type="text" value=""></td>
</tr></br>
<tr>
<td><font face="Arial, Helvetica, sans-serif">Fax:</font></td>
<td><input type="text" name="Fax"></td>
</tr></br>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit"
value="Send"></td>
</tr></br>
</table>
</form>
}
<p>
<?php
if($_POST['trigger']=="go"){
error_reporting(0);
$recipient = 'aaron@example.com';
$from = stripslashes($_POST['Name']);
$e-mail = stripslashes($_POST['E-mail']);
$phone = stripslashes($_POST['Phone']);
$fax = stripslashes($_POST['Fax']);
}
if (mail($recipient, $name, $e-mail, $phone, $fax))
echo nl2br("<b>Message Sent:</b>
To: $recipient
Name: $name
E-mail: $e-mail
Phone: $phone
Fax: $fax
$msg");
}
else{
echo "Message failed to send";
}
?>

im not sure about this bit

if (mail($recipient, $name, $e-mail, $phone, $fax))
should you use isset() with this?

else{
echo "Message failed to send";
}

not sure you need this either as you should get a mail error from the server anyways if something is missing such as an address

ake15

3:19 pm on Mar 28, 2008 (gmt 0)

10+ Year Member



line 101-120

<?php
} else {
error_reporting(0);
$recipient = 'aaron@example.com';
$from = stripslashes($_POST['Name']);
$e-mail = stripslashes($_POST['E-mail']);
$phone = stripslashes($_POST['Phone']);
$fax = stripslashes($_POST['Fax']);
if (mail($recipient, $name, $e-mail, $phone, $fax))
echo nl2br("<b>Message Sent:</b>
To: $recipient
Name: $name
E-mail: $e-mail
Phone: $phone
Fax: $fax
$msg");
else
echo "Message failed to send";
}
?>

[edited by: jatar_k at 3:20 pm (utc) on Mar. 28, 2008]

jatar_k

12:05 am on Mar 29, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



maybe try changing this

$e-mail = stripslashes($_POST['E-mail']);

to

$email = stripslashes($_POST['E-mail']);

ake15

2:58 pm on Mar 29, 2008 (gmt 0)

10+ Year Member



i changed that and everywhere else there needed to be "email" and now its giving me all these

}

Notice: Undefined index: trigger in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 103

Notice: Undefined variable: recipient in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111

Notice: Undefined variable: name in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111

Notice: Undefined variable: email in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111

Notice: Undefined variable: phone in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111

Notice: Undefined variable: fax in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111

Warning: mail() [function.mail]: SMTP server response: 503 5.5.2 Need Rcpt command. in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
if (mail($recipient, $name, $email, $phone, $fax)) else{ echo "Message failed to send"; }

ake15

3:47 pm on Mar 31, 2008 (gmt 0)

10+ Year Member




System: The following 2 messages were spliced on to this thread from: http://www.webmasterworld.com/php/3615421.htm [webmasterworld.com] by dreamcatcher - 8:26 pm on Mar. 31, 2008 (utc 0)


hey im really new to this php...i made a form and it shows up on the site but it also shows all this...

}

Notice: Undefined index: trigger in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 103

Notice: Undefined variable: recipient in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111

Notice: Undefined variable: name in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111

Notice: Undefined variable: email in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111

Notice: Undefined variable: phone in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111

Notice: Undefined variable: fax in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111

Warning: mail() [function.mail]: SMTP server response: 503 5.5.2 Need Rcpt command. in E:\CustomerData\webspaces\webspace_00152424\wwwroot\register.php on line 111
if (mail($recipient, $name, $email, $phone, $fax)) else{ echo "Message failed to send"; }

how do i fix this?

bilenkyj

3:49 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



wasnt this part of your email query you had going the other day?, shouldnt you keep this to that?

[webmasterworld.com...]

i think you have set this up wrong,

you want it so that the if statements run when the form is submitted - the function mail() is within the if statement -

the else isnt needed i think - you could have the error message pop up if one of your fomr fields is empty - this will cause the mail() function to fail. mail() will give an error if a parameter is wrong, follow the script suggested on our original thread

dreamcatcher

8:27 pm on Mar 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Threads merged.

dc

PHP_Chimp

7:43 pm on Apr 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



An undefined index is where you are trying to use an array key that doesnt exist i.e.

$array = array('one' => 'value 1', 'two' => 'value 2');
echo $array['three']; // undefined index
echo $array['One']; // also undefined [b]o[/b]ne != [b]O[/b]ne

undefined variable is a similar thing, but you dont have that variable i.e.

$this = 'this';
$that = 'that';
echo $another; // undefined variable
echo $This; // also undefined [b]t[/b]his != [b]T[/b]his

So you need to have a look on the lines in the error and see what variables and indexes are undefined.

Also $array['E-mail'] and $E-mail are not the same thing (first is a single element from the $array...array, the second is a variable). So make sure that you have arrays and variable at the correct places.

ake15

8:40 pm on Apr 1, 2008 (gmt 0)

10+ Year Member



alright this is wut i got:

if mail($recipient, $name, $email, $phone, $fax)
echo nl2br("<b>Message Sent:</b>
To: $recipient
Name: $name
E-mail: $email
Phone: $phone
Fax: $fax
$msg");

does it have to do somethin with the $msg since i dont have it in the if mail(...)?

ake15

8:46 pm on Apr 1, 2008 (gmt 0)

10+ Year Member



those are line 111-118 and it says that the undefined variable is on line 111