+ Reply to Thread
Results 1 to 7 of 7

Thread: php help

  1. #1
    swirly's Avatar
    swirly is offline x10 Elder swirly is an unknown quantity at this point
    Join Date
    Jul 2005
    Location
    NC
    Posts
    965

    php help

    well that was the wrong code i figured out...but now i got the right one...but its not working....its for people to add names and passwords etc..but its not submitting, and i copied it straight out of the book. did i just spell something. heres the code...
    Code:
    <html>
    <head>
    <title>Add User</title></head>
    
    <?php
    if( (!$firstname) or (!$lastname)
                                   or (!$username) or (!$password) )
    {
    $form ="Please enter all new user details...";
    $form.="<for action=\"$PHP_SELF\"";
    $form.=" method=\"post\">First Name: ";
    $form.="<input type=\"text\" name\"firstname\"";
    $form.="value=\"$firstname\"><br>Last Name: ";
    $form.="<input type=\"text\" name\"lastname\"";
    $form.="value=\"$lastname\"><br>User Name: ";
    $form.="<input type=\"text\" name\"username\"";
    $form.="value=\"$username\"><br>Password: ";
    $form.="<input type=\"text\" name\"password\"";
    $form.="value=\"$password\"><br>";
    $form.="<input type=\"submit\" value=\"Submit\">";
    $form.="</form>";
    echo($form);
    }
    else
    { $conn = @mysql_connect("localhost", "swirlys", "friends")
    or die("Could not connect to MYSQL");
    
    $db = @mysql_select_db("swirlys_user", $conn)
    or die("could not select database"); 
    
    $sql = "insert into users
    (first_name,last_name,user_name,password) values
    (\"$firstname\",\"$lastname\",\"$username\",
                                   password(\"$password\") )";
    $result =@mysql_query($sql,$conn)
    or die("Could not execute query");
    if($result) {echo("New user $username added"); }
    }
    ?></body</html>
    Last edited by swirly; 05-04-2006 at 02:39 PM.
    Don't go to bed angry, stay awake and plot revenge.

  2. #2
    lambada's Avatar
    lambada is offline x10 Elder lambada is an unknown quantity at this point
    Join Date
    Mar 2006
    Location
    Caister, Gt Yarmouth, Norfolk, ENGLAND
    Posts
    1,222

    Re: php help

    You missed out the opening body tag, and the '>' off the closing body tag.

    Thats all I can see.
    Lambada - the former Account Manager (before I resigned)




  3. #3
    Xenon Design's Avatar
    Xenon Design is offline x10Hosting Member Xenon Design is an unknown quantity at this point
    Join Date
    May 2006
    Location
    Behind your couch!
    Posts
    80

    Re: php help

    Heres another mistake:
    $form.="<for action=\"$PHP_SELF\""; .... you missed the m in form

    Website under construction -- Ask me anything about Web 2.0

  4. #4
    randomize's Avatar
    randomize is offline x10 Lieutenant randomize is an unknown quantity at this point
    Join Date
    Mar 2006
    Posts
    337

    Re: php help

    Quote Originally Posted by swirly
    Code:
    {
    $form ="Please enter all new user details...";
    $form.="<for action=\"$PHP_SELF\"";
    $form.=" method=\"post\">First Name: ";
    $form.="<input type=\"text\" name\"firstname\"";
    $form.="value=\"$firstname\"><br>Last Name: ";
    $form.="<input type=\"text\" name\"lastname\"";
    $form.="value=\"$lastname\"><br>User Name: ";
    $form.="<input type=\"text\" name\"username\"";
    $form.="value=\"$username\"><br>Password: ";
    $form.="<input type=\"text\" name\"password\"";
    $form.="value=\"$password\"><br>";
    $form.="<input type=\"submit\" value=\"Submit\">";
    $form.="</form>";
    echo($form);
    }
    Look at the the code in red then look at the code in orange.

    There is a dot missing at the end of the "form" on the very first line.

    I dunno if that is an error but I just thought I would point it out to you guys anyway!


    Click the animation above to go to the site where they are created!

    \ /
    (.) (.)
    /_
    \_____/
    The Evil Guy will take over all Signatures. Please help him to do this by copying and pasting him into your Signature.
    Thank you For Helping Evil!

  5. #5
    flapietoetoe is offline x10 Sophmore flapietoetoe is an unknown quantity at this point
    Join Date
    Aug 2005
    Posts
    113

    Re: php help

    What error does it give?
    That would be alot more helpfull then just posting it doesnt work

  6. #6
    The_Magistrate's Avatar
    The_Magistrate is offline x10 Elder The_Magistrate is an unknown quantity at this point
    Join Date
    May 2005
    Location
    PA
    Posts
    559

    Re: php help

    Quote Originally Posted by randomize
    Look at the the code in red then look at the code in orange.
    There is a dot missing at the end of the "form" on the very first line.
    I dunno if that is an error but I just thought I would point it out to you guys anyway!
    That's not an error, the dot (.) is used to concatenate two strings together. (i.e. $form = "String from line 1" + "String from line 2")

    Also, global varables are turned on here at X10, so you'll need to use
    Code:
    if(isset($_POST['firstname']))
       $firstname = $_POST['firstname'];
    if(isset($_POST['lastname']))
       $lastname = $_POST['lastname'];
    if(isset($_POST['username']))
       $username = $_POST['username'];
    if(isset($_POST['password']))
       $password = $_POST['password'];
    Add that to the top of your script and you should be golden.
    Last edited by The_Magistrate; 05-22-2006 at 09:49 PM.
    Getting Started | Terms of Service | Paid Hosting | Forum Rules | Free Server Status | Banned Countries

    If I have helped you through one of my posts, please click the
    blue checkbox on the right below my avatar to add to my reputation.

  7. #7
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: php help

    Quote Originally Posted by The_Magistrate
    Also, global varables are turned on here at X10, so you'll need to use
    PHP Code:
    if(isset($_POST['firstname']))
       
    $firstname $_POST['firstname'];
    if(isset(
    $_POST['lastname']))
       
    $lastname $_POST['lastname'];
    if(isset(
    $_POST['username']))
       
    $username $_POST['username'];
    if(isset(
    $_POST['password']))
       
    $password $_POST['password']; 
    Add that to the top of your script and you should be golden.
    Good point.. Register Globals, I believe, is turned off on x10's free server. I'm surprised I didnt' catch that earlier when I looked at this..

+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  4. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  5. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers