Im a newbie and Im sure Im missing something simple here. I can connect to Mysql and validate anything on the server already and echo results if my input is empty, but I cannot insert anything. This is basically a form that inserts email and a name attribute on an already existing List created by PHPList. It first check if the user exists, if so returns info on them. If they dont it is supposed to create the parameters for them. I've been staring at this for a day and tried anything I can get my hands on. I hope its something simple that I am missing...any suggestions?
Code: Select all
<?php
error_reporting(E_ALL);
$name = 'Herb';
$email = "herb@gmail.com";
require("maillist/config/config.php");
$db = mysql_connect("localhost", "$database_user", "$database_password") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("$database_name") or die(mysql_error());
echo "Connected to Database<br />";
$att = mysql_query("SELECT userid FROM phplist_user_user_attribute WHERE value='$name'") or die(mysql_error());
$id = mysql_fetch_array($att);
echo "hello".$id['userid'];
$exusr = mysql_query("SELECT id FROM phplist_user_user WHERE email='$email'") or die(mysql_error());
$userId = mysql_fetch_array($exusr);
if (empty($userId)) {
echo '$userId is empty';
{
$uniqueId = md5(uniqid(mt_rand(0,1000).$email));
$uid = mysql_query("SELECT COUNT(*) FROM phplist_user_user WHERE uniqid='($uniqueid)'") or die(mysql_error());
$exists = mysql_fetch_array($uid);
} while ($exists);
$insert = mysql_query ("INSERT INTO phplist_user_user (email,entered,confirmed,uniqid) values ('$email',now(),1,'$uniqueId')") or die(mysql_error());
$result = mysql_fetch_array($insert);
$getid = mysql_query ("SELECT id FROM phplist_user_user WHERE uniqid='$uniqueId'") or die(mysql_error());
$newid = mysql_fetch_array($getid);
echo "New User Created:".$newid['id'];
}else{
echo "User ID:".$userId['id'];
}
?>