Jump to content

PHP if statement


PC Nerd

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>";
}
Link to comment
https://forums.phpfreaks.com/topic/13002-php-if-statement/
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
Link to comment
https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50006
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]
Link to comment
https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50017
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.
Link to comment
https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50018
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!
Link to comment
https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50020
Share on other sites

Archived

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

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