Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: PHP syntax help

  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP syntax help

    Hi,I have a script that validates if a users password is correct. If the password is correct I want to add a button for the

    user to continue. The script below displays the button if the user is valid or not. When I move the button code to after the

    line (echo "Welcome back $Username" I get a parse error. I have also tried to echo out the button like the first 4 lines

    below but this doesnt work either. Any ideas?? Also what is the simplest way to set a cookie?
    ps I'm new to PHP if this seems easy

    PHP Code:
    echo "<form action= "login_display.php" method="post">";
    echo 
    "<input type="submit" value="Continue">";
    echo 
    "<input type=\"hidden\" name =\"Username\" value=$Username>";
    echo 
    "</form>"
    PHP Code:
    //Password Validate
    <?php
    include ("customers_inc.php");

    $query"SELECT Password FROM customer_details WHERE Username='$Username'";
    $result=mysql_query($query);
    $num=mysql_num_rows($result);

    if (
    $num ==0)
    {
    echo 
    "The database contains no contacts yet";
    }
    else
    {
    echo 
    "<b><centre> Contacts</centre></b><br><br>";
    ?>


    <?
    $i
    =0;
    while (
    $i<$num)
    {
    $db_Password=mysql_result($result$i"Password");
    ?>


    <?
    $i
    ++;
    }
    //60
    echo "</table>";
    }
    ?>
    <?
    if (($db_Password)===($Password))
    {
    echo 
    "Welcome back $Username";
    }
    else
    {
    echo 
    "<b><centre> Invalid user</centre></b><br><br>";
    echo 
    "Please try again <a href=\"index2.php\"> Insert details</a><br>";
    }
    ?>
    <form action= "login_display.php" method="post">
    <input type="submit" value="Continue"> 
    <? echo "<input type=\"hidden\" name =\"Username\" value=$Username>"?>
    </form>
    Thanks in advance for any help
    Last edited by Spookster; 06-23-2006 at 02:35 AM.

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    In the future please use the forum php code tags to post php code. Makes it easier to read.

    What did the parse error say?
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    If you're going to echo out html...it's simplest to use single quotes(you're not escaping your double quotes in double quotes in all places)..no need to use double quotes when you don't need to interpolate:
    PHP Code:
    echo '<form action= "login_display.php" method="post">';
    echo 
    '<input type="submit" value="Continue">';
    echo 
    '<input type="hidden" name ="Username" value="' $Username '">';
    echo 
    '</form>'
    Cookies:
    http://us2.php.net/manual/en/function.setcookie.php

  • #4
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Spookster
    In the future please use the forum php code tags to post php code. Makes it easier to read.

    What did the parse error say?
    Parse error: parse error in c:\apache\htdocs\ayr_store\password_validate.php on line 37


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •