PHP will not post vars.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charlie T

    PHP will not post vars.

    When every I submit my form information it just puts the <?php echo
    $PHP_SELF?> as part of the URL. Please help....

    ---------------------------------------------------------------
    <html>
    <body>

    <?php
    if ($submit){
    //connect to database
    //$host = "host";
    //$user = "user";
    //$pass = "**";
    //$database = "driveaf";

    $db = mysql_connect(" host", "genuser", "pasword");
    mysql_select_db ("driveaf", $db);
    //Connected to data base
    //write data to db
    $sql = "INSERT INTO users (empID, firstname, lastname, email,
    password, reg_date, website) VALUES ('$empID', '$firstname',
    '$lastname', '$email', PASSWORD('$pass word'), '$reg_date',
    '$website')";
    $result = mysql_query($sq l);
    echo "Thanks";
    }else{
    //

    ?>


    <form method="post" action="<?php echo $PHP_SELF?>">
    <p>Employee ID:
    <input name="empID" type="text" id="empID">
    </p>
    <p>First Name:
    <input name="firstname " type="text" id="firstname" >
    </p>
    <p>Last Name:
    <input name="lastname" type="text" id="lastname">
    </p>
    <p>email address:
    <input name="email" type="text" id="email">
    </p>
    <p>password:
    <input name="password" type="text" id="password">
    </p>
    <p>
    <input name="submit" type="Submit" value="Submit">
    </p>
    </form>



    </body>
    </html>
    -----------------------------------------------------------------------
  • Matthias Esken

    #2
    Re: PHP will not post vars.

    Charlie T wrote:
    [color=blue]
    > When every I submit my form information it just puts the <?php echo
    > $PHP_SELF?> as part of the URL. Please help....[/color]

    Are you sure that PHP is running on your machine? And are you really
    sure that PHP does not use the default value for register_global s? If
    resgister_globa ls is off (default!), then have a look at the following
    changes:
    [color=blue]
    > <?php
    > if ($submit){[/color]

    Should be:
    if (isset($_POST['submit'])) {
    [color=blue]
    > $sql = "INSERT INTO users (empID, firstname, lastname, email,
    > password, reg_date, website) VALUES ('$empID', '$firstname',
    > '$lastname', '$email', PASSWORD('$pass word'), '$reg_date',
    > '$website')";[/color]

    $sql = "
    INSERT INTO users (
    empID,
    firstname,
    lastname,
    email,
    password,
    reg_date,
    website
    )
    VALUES (
    $_POST['empID'],
    '$_POST[firstname]',
    '$_POST[lastname]',
    '$_POST[email]',
    PASSWORD($_POST[password]),
    '$_POST[reg_date]',
    '$_POST[website]')
    ";

    [color=blue]
    > <form method="post" action="<?php echo $PHP_SELF?>">[/color]

    <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">

    Regards,
    Matthias

    Comment

    Working...