Hiya, im tryin to make a script that will allow users to submit a review of services through a form. Data goes into a mysql db, then later ill want to retrieve certain fields to display, as seen on many sites.
I know there are tons of scripts already made, but id rather make this one myself, since im still a bit new to php.
anyways, i have the form made and the sql functons are all working, but my error checking is a jumble and ive revised the code nearly 40 times already (according to the auto-increment field :rolleyes: ) and starting to get frustrated, i just dont see why it wont work.
Heres what i got so far.
$host="localhost";
$uname="xxxxxx";
$pass="xxxxxx";
$db="reviews";
$table="reviews";
$form =" A Pretty long Form"; //SET THE FORM
if ($_POST[op]!="ds")
{
echo $form; //SHOW THE FORM
}
elseif ($_POST[op]="ds")
{ //START CHECKING INPUT
if ($_POST['firstname']="")
{
$err1="<b><font color=\"#FF0000\">Please Fill In Your Firstname</font></b><br>";
$send="no";
}
if ($_POST['lastname']="")
{
$err2="<b><font color=\"#FF0000\">Please Fill In Your Lastname</font></b><br>";
$send="no";
}
if ($_POST['email']="")
{
$err3="<b><font color=\"#FF0000\">Please Fill In You Email</font></b><br>";
$send="no";
}
if ($_POST['website']="")
{
$err4="<b><font color=\"#FF0000\">Please Fill In Your Website</font></b><br>";
$send="no";
}
if ($_POST['newreview']="")
{
$err5="<b><font color=\"#FF0000\">Please Submit a Review</font></b><br>";
$send="no";
}
if ($_POST['uptime']="")
{
$err6="<b><font color=\"#FF0000\">Please Select Uptime & Reliability</font></b><br>";
$send="no";
}
if ($_POST['support']="")
{
$err7="<b><font color=\"#FF0000\">Please Select From Technical Support</font></b><br>";
$send="no";
}
if ($_POST['customer']="")
{
$err8="<b><font color=\"#FF0000\">Please Select From Customer Service</font></b><br>";
$send="no";
}
if ($_POST['status']="")
{
$err9="<b><font color=\"#FF0000\">Please Select From Billing Status</font></b><br>";
$send="no";
}
if ($_POST['duration']="")
{
$err10="<b><font color=\"#FF0000\">Please Select From Time With The Company</font></b><br>";
$send="no";
}
if ($_POST['plan']="")
{
$err11="<b><font color=\"#FF0000\">Please Select Plan Used</font></b><br>";
$send="no";
}
}
elseif ($send=="no")
{
echo $err1;
echo $err2;
echo $err3;
echo $err4;
echo $err5;
echo $err6;
echo $err7;
echo $err8;
echo $err9;
echo $err10;
echo $err11;
echo $form;
exit();
}
//CONNECT TO THE DATABASE
$connection=@mysql_connect($host, $uname, $pass)or die("Could not connect to database:". mysql_errno());
$dbs=@mysql_select_db($db, $connection)or die("Database does not exist:".mysql_errno());
//CHECK THE USER INPUT FOR KEY FIELDS
$check="select firstname, lastname, email, ip, website from $table where firstname='$_POST[firstname]'AND lastname='$_POST[lastname]'AND email='$_POST[email]' AND ip='$_POST[ip]' AND website='$_POST[website]'";
//GET THE RESULT
$result=mysql_query($check, $connection)or die("Could not obtain results:".mysql_errno());
$result_num=mysql_num_rows($result);
//GET # OF RESULTS AND DO ACTION
if ($result_num<1)
{
$sql_q="INSERT INTO $table VALUES('', '$_POST[firstname]', '$_POST[lastname]', '$_POST[email]', '$_POST[ip]', '$_POST[website]', '$_POST[newreview]', '$_POST[uptime]', '$_POST[support]', '$_POST[customer]', '$_POST[status]', '$_POST[duration]', '$_POST[plan]',now())";
//GET RESULT OF THE ADDITION
$result_add=mysql_query($sql_q, $connection) or die("Could not insert into database:".mysql_error());
$form="<h1> Your review has been submitted, thank you for your time.</h1>";
}
else
{
$form="<h1>We're sorry, it appears you have already entered a review. Thank you again</h1>";
}
Im totally lost now what to do, seems to be so close, any help would be greatly appreciated.
Thanks.