I have tried tweaking this code in every way imaginable (to me at least) with no success.. the query does not insert the data into my db so my form still does not work.. help???
[code=php]
include(‘inc/db.php’);
$error;
if($_SERVER[‘REQUEST_METHOD’]==’POST’){
$info[‘fname’] = stripslashes(htmlspecialchars($_POST[‘fname’]));
$info[‘lname’] = stripslashes(htmlspecialchars($_POST[‘lname’]));
$info[‘username’] = stripslashes(htmlspecialchars($_POST[‘username’]));
$info[’email’] = stripslashes(htmlspecialchars($_POST[’email’]));
$info[‘password1’] = stripslashes(htmlspecialchars(sha1($_POST[‘password1’])));
$info[‘password2’] = stripslashes(htmlspecialchars(sha1($_POST[‘password2’])));
$info[‘addr_line1’] = stripslashes(htmlspecialchars($_POST[‘addr_line1’]));
$info[‘addr_line2’] = stripslashes(htmlspecialchars($_POST[‘addr_line2’]));
$info[‘state_prov’] = stripslashes(htmlspecialchars($_POST[‘state_prov’]));
$info[‘city’] = stripslashes(htmlspecialchars($_POST[‘city’]));
$info[‘country’] = stripslashes(htmlspecialchars($_POST[‘country’]));
if($info[‘addr_line2’]==”ADDRESS LINE 2″){
$info[‘addr_line2′]=””;
}
if (!isset($error)) {
foreach( $info as $value ){
if( stripos($value,’Content-Type:’) !== FALSE ){
$error = “There was a problem with the information you entered.”;
} else
if($value!=$info[‘addr_line2′] && $value==””){
$error=”All sections must be completed”;
}
}
} else if(!isset($error) &&
!preg_match(“/^([a-z0-9_.-]+)@([da-z.-]+).([a-z.]{2,6})$/”, $info[’email’])){
$error=”Email is invalid”;
} else if(!isset($error) && strlen($info[‘password1’])<8){
$error=”Password must be 8 or more characters.”;
} else if(!isset($error) && $info[‘password1’]!=$info[‘password2’]){
$error=”Passwords do not match. Please try again.”;
} else if(!isset($error)){
$addr = $info[‘addr_line1’].” “.$info[‘addr_line2’].” “.$info[‘city’].” “.$info[‘state_prov’].” “.$info[‘country’];
try{
$db->query(“INSERT INTO members (fname, lname, username, email, pass, addr) VALUES (‘”.$info[‘fname’].”‘,'”.$info[‘lname’].”‘,'”.$info[‘username’].”‘,'”.$info[’email’].”‘,'”.$info[‘password1’].”‘,'”.$info[‘addr’].”‘)”);
}catch(Exception $e){
$error = “Could not execute query”;
}
}
}
I have looked at the db access info and all the creds are correct so I’m clueless as to whats going on here.