Okay I am rewriting a script to update multiple DBs. I had trouble getting the syntax correct to get it to update multiple DBs thats another thread, which I think I have it resolved. However my question now is how do I make the if statement in line 58 include all the DB queries to update and not just one. Every variation I have tried I either get an error or it has an unexpected end. I suck when it comes to if statements. Any help would be greatly appreciative and thank you all if you have ever helped me in the past with my piddly coding🙂
<?
include "config.php"; // database connection
$ak=$_POST['ak'];
$userid=$_POST['userid'];
$todo=$_POST['todo'];
$password=$_POST['password'];
$password2=$_POST['password2'];
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>thescript</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
$userid=mysql_real_escape_string($userid);
$ak=mysql_real_escape_string($ak);
$tm=time()-86400;
if(!mysql_num_rows(mysql_query("SELECT userid FROM actove WHERE entry='$ak' and userid='$userid' and time > '$tm' and status='pending'"))){
echo "<center><font face='Verdana' size='2' color=red><b>Your activation code is out of date. </b></font> ";
exit;
}
//Show the change password form//
if(isset($todo) and $todo=="new-password"){
$password=mysql_real_escape_string($password);
//Setting flags for checking
$status = "GOOD";
$msg="";
if ( strlen($password) < 6 or strlen($password) > 12 ){
$msg=$msg."Password must be more than 6 char legth and maximum 12 char lenght<BR>";
$status= "FAIL";}
if ( $password <> $password2 ){
$msg=$msg."Both passwords are not matching<BR>";
$status= "FAIL";}
if($status<>"GOOD"){
echo "<font face='Verdana' size='2' color=red>$msg</font><br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
}else{ // if all validations are passed.
$password=md5($password);
if(mysql_query("update pla_user set pass ='$password' where id='$userid'")){
$conn_new_1=mysql_connect("localhost", "xxxx", "xxxx");
mysql_select_db("pbod_clome") or die("db cant open");
$db_new_1=mysql_query("update pbod_users set password='$password' where id='$userid'",$conn_new_1);
$conn_new_2=mysql_connect("localhost", "xxxx", "xxxx");
mysql_select_db("lopis1_killer") or die("db cant open");
$db_new_2=mysql_query("update loke_user set password ='$password' where id='$userid'",$conn_new_2);
$tm=time();
$tt=mysql_query("update key_act set status='done' where pkey='$ak' and userid='$userid' and status='pending'");
echo "<font face='Verdana' size='2' ><center>Thanks <br> Your password has been changed. </font></center>";
}else{echo "<font face='Verdana' size='2' color=red><center>Sorry <br> Failed to create new password please contact the admin. </font></center>";
}
}
}
?>
<center><a href=index.php?page=login>Login</a>
<br><br></center>
</body>
</html>