$_POST wont return a value

Discussion in 'PHP' started by rianne809, Dec 3, 2007.

  1. #1
    Hi guys, im currently new in php programming, i have read some php tutorials and so i created a login script, my problem is the $_POST variable wont return any data, how is this so, below is my script

    <?php
    // check for cookies
    if (isset($_COOKIE['logcheck'])){
    header("Location: index.html");
    }else{
    $usernam= "some username";
    $passwod="";
    $database="some database";

    mysql_connect(localhost,$usernam,$passwod);
    @mysql_select_db($database) or die( "Unable to select database");

    $user = $_POST['formtext1'];
    $pass = $_POST['formtext2'];

    $query = "SELECT * FROM nsuser WHERE usr_name='$user'";
    $result = mysql_query($query);

    $num = mysql_num_rows($result);

    mysql_close();

    if ($num==0){
    header("Location: errorlog.html");
    }else{
    $passcheck = mysql_result($result,0,"usr_pass");
    if ($pass==$passcheck){
    // set logcheck cookies valid for 1 minute
    setcookie("logcheck","yes",time()+60);
    header("Location: index.html");
    }else{
    header("Location: reports_error.html");
    }
    }
    }
    ?>

    ive' tried to echo the $user variable to find out its value, but the page return was blank, does it means that there is no value for it? Srry for being a noob here :eek:


    btw, here is my form code:

    <form name="form1" method="POST" action="log.php" enctype="text/plain">
    <input name="formtext1" type="text" id="formtext1" style="position:absolute;width:142px;left:64px;top:183px;z-index:8">
    <input name="formtext2" type="password" id="formtext2" style="position:absolute;width:145px;left:62px;top:223px;z-index:9">
    <input name="formbutton1" type="submit" value="Submit" style="position:absolute;left:98px;top:261px;z-index:12">
    </form>
     
    rianne809, Dec 3, 2007 IP
  2. thenetninja

    thenetninja Peon

    Messages:
    314
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i got it, your enctype is not multipart (in the form code) =)
     
    thenetninja, Dec 3, 2007 IP
  3. rianne809

    rianne809 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Its working now yey =) , geez im so noob lol, thanks a lot, i bet youll be hearing a lot from me soon lol
     
    rianne809, Dec 3, 2007 IP
  4. thenetninja

    thenetninja Peon

    Messages:
    314
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i'll remember to attach a 0500 number to my profile for that sort of help lol
     
    thenetninja, Dec 3, 2007 IP