Re: Please help a newbie

From: Date: Sun, 19 Apr 2009 09:53:53 +0000
Subject: Re: Please help a newbie
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-46123@lists.php.net to get a copy of this message
Rij wrote:
I input the values from a HTML form. Here is the partial code.
        $phone = $_POST['phone'];
        $name  = $_POST['name'];
        $address = $_POST['address'];
        $query = "INSERT INTO contacts VALUES ('$phone', '$name', '$address')";
        if (mysql_query($query, $con)) echo "Values inserted";
        else die('Unable to create table : '.mysql_error());
This is unsafe code. I suggest you lookup "prepared statements" and the PDO library (which is part of PHP). Daniel.

« previous php.db (#46123) next »