insert IF issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

insert IF issue

Post 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>";*/
    }
       ?>
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: insert IF issue

Post by pbs »

I think you missed mysql_query($sql)
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: insert IF issue

Post 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!
Post Reply