Page 1 of 1

insert IF issue

Posted: Fri Feb 26, 2010 5:40 am
by aravona
I have an if statement where I want an insert statement to run only if one variable equals another variable, ie. they have to be identical.

However the information isn't being passed into my database.

Code: Select all

 
<?php
    include("connection.php");
    $username = $_POST['newuser'];
    $password = $_POST['newpass'];
    $password2 = $_POST['newpasscheck'];
    
    if ($password == $password2) {
    $sql = sprintf("INSERT INTO userdetails (username, password, userlevel, joindate) VALUES ('$username', md5
 
('$password'), 'Member', curdate()) ",
       mysql_real_escape_string($username),
       mysql_real_escape_string($password));
echo $sql;
/*echo "<head><meta HTTP-EQUIV='REFRESH' content='00; url=profile.php'></head>";*/
    }
    else {
    echo "your passwords did not match";   
    /*echo "<head><meta HTTP-EQUIV='REFRESH' content='5; url=index.php'></head>";*/
    }
       ?>

Re: insert IF issue

Posted: Fri Feb 26, 2010 5:48 am
by pbs
I think you missed mysql_query($sql)

Re: insert IF issue

Posted: Fri Feb 26, 2010 5:54 am
by aravona
Sigh, may I say OMG... this is what I get for squeezing my own projects inbetween work ones :P

Cheers for humouring me mate!