Jump to content

Archived

This topic is now archived and is closed to further replies.

PC Nerd

PHP if statement

Recommended Posts

Hey guys

im still having trouble with my if statements. im writing a script which checks form input. When i check the emails confirmation, php tells me that there is an unexpected "}". this is the closing curly brace for my if loop



can anyone help me......


My code is


if($_POST[Email] != $_POST[Email-confirm])
{
echo "Your Email was not correctly confirmed, please make sure that you enter the same Email in both fields.<br><br>";
}

Share this post


Link to post
Share on other sites
Can you post the code for the for loop. As the code you have provided is fine.

Also make sure you place apostrophes ' around your indexes for your arrays like so:
[code]if($_POST['Email'] != $_POST['Email-confirm'])[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=388416:date=Jun 27 2006, 07:13 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 27 2006, 07:13 PM) [snapback]388416[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Can you post the code for the for loop. As the code you have provided is fine.

Also make sure you place apostrophes ' around your indexes for your arrays like so:
[code]if($_POST['Email'] != $_POST['Email-confirm'])[/code]
[/quote]


thanks, ill give it a go

Share this post


Link to post
Share on other sites
No thats not the solution! I need you to post your for loop code here.

Share this post


Link to post
Share on other sites
i tried it and it didnt work. the error is:

Parse error: syntax error, unexpected '}' in /WEB SITE/public_html/game/Email_Sender.php on line 30

Share this post


Link to post
Share on other sites
I told you twice! POST the code for your forl oop! The bit I told you to change was just a suggestion, it wasnt a soloution.

Share this post


Link to post
Share on other sites
Fine, but it wont help.

[code]<?php

$newLine = "/n";

echo "The infomation you entered is as follows.  If it is incorrect, please re enter the information <a href = 'Emails.php'>here</a><br><br>";


foreach($_POST as $field => $value){
if(empty($_POST[$field])){

echo "You left the <font color = 'red'>$field</font> field empty.  If you want to submit the request please go back and fill in this field,  <br><br>";

echo "<a href = 'Emails.php'>click here to restart request</a>";
echo "<br><br>";
}


else{

continue;
}
}


if($_POST['Email'] != $_POST['Email-confirm'])
{
echo "Your Email was not correctly confirmed, please make sure that you enter the same Email in both fields.<br><br>";
}

else{break}

echo "The information you gave was:<br><br>";

echo "$_POST[First_Name], ";
echo "$_POST[Last_Name]<br>";
echo "$_POST[Age] yrs old<br><br>";
echo "$_POST[Email]<br><br>";
echo "$_POST[Reason]";

}

?>
[/code]

Share this post


Link to post
Share on other sites
Sorted your problems out.
[code]$newLine = "/n";

echo "The infomation you entered is as follows.  If it is incorrect, please re enter the information <a href = 'Emails.php'>here</a><br><br>";


foreach($_POST as $field => $value)
{
    if(empty($_POST[$field]))
    {
        echo "You left the <font color = 'red'>$field</font> field empty.  If you want to submit the request please go back
        and fill in this field,  <br><br>";

        echo "<a href = 'Emails.php'>click here to restart request</a>";
        echo "<br><br>";
    }
}

if($_POST['Email'] != $_POST['Email-confirm'])
{
    echo "Your Email was not correctly confirmed, please make sure that you enter the same Email in both fields.<br><br>";
}
else
{
    echo "The information you gave was:<br><br>";

    echo "$_POST[First_Name], ";
    echo "$_POST[Last_Name]<br>";
    echo "$_POST[Age] yrs old<br><br>";
    echo "$_POST[Email]<br><br>";
    echo "$_POST[Reason]";
}[/code]
Your had an extra un-needed closing } braket in your code.

Share this post


Link to post
Share on other sites
sorted your problems out.


thanks, that code was really being annoying


thanks,

Share this post


Link to post
Share on other sites
Guest edwinsweep
hi pc nerd.
i used to have the same mistake's as you have now.
jedit made it alot easyer for me
its a javascript based editor also suitable for PHP.
jedit also keeps track of al the opening and closing tags in your script.
and it changes color realtime so HTML is a different color than PHP, and mysql is yet another color.
if you dont see the color's working in jedit its because you havent saved the file as a .PHP file yet.
they say zend studio is also a good development platform.
i havent tried it to be honest.
good luck and cya later!

Share this post


Link to post
Share on other sites

×

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.