mrcoda Posted May 9, 2010 Share Posted May 9, 2010 I need to first check the form using JS client side, then server side as a back up , then send an email notification to myself and the user , and then update my database, its a quick call back form that adds to my customer database. Heres the form <div class="requestacallform"> <form method="post" id="quickcontact" name="quickcontact" action="update_quickcontacts.php"><fieldset> <ul id="quickcontactform"> <li>name<input name="name" type="text" size="15" maxlength="30" /></li> <li>company<input name="company" type="text" size="15" maxlength="50" /></li> <li>phone<input name="phone" type="text" size="15" maxlength="30" /></li> <li>email<input name="email" type="text" size="15" maxlength="50" /></li> <li><input type="submit" value="send" class="submitbutton" onClick="return checkForm();" /></li> </ul></fieldset> </form> </div> The javascript is ok, but the following php isnt right. The connect to database works on its own , its how I join the two together. The validation and the update. <?php $errmsg = ''; // error message $name = ''; // sender's name $company = ''; // the message itself $email = ''; // sender's email addres $phone = ''; // message subject if(isset($_POST['send'])) { $name=$_POST["name"]; $company=$_POST["company"]; $email=$_POST["email"]; $phone=$_POST["phone"]; if(trim($sname) == '') { $errmsg = 'Please enter your name'; } else if(trim($email) == '') { $errmsg = 'Please enter your email address'; } else if(!isEmail($email)) { $errmsg = 'Your email address is not valid'; } else if(trim($subject) == '') { $errmsg = 'Please enter message subject'; } else if(trim($message) == '') { $errmsg = 'Please enter your message'; } if($errmsg == '') { if(get_magic_quotes_gpc()) { $subject = stripslashes($subject); $message = stripslashes($message); } $to = "[email protected]"; $subject = '[Contact] : ' . $subject; $msg = "From : $sname \r\n " . $message; mail($to, $subject, $msg, "From: $email\r\nReturn-Path: $email\r\n"); mysql_connect ("localhost", "rbcreati_richard", "burb1971") or die ('Error: ' . mysql_error()); mysql_select_db ("rbcreati_clients"); $query = "INSERT INTO quickcontacts VALUES ('','$name','$company','$email','$phone')"; mysql_query($query); mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/201196-help-me-validating-form-then-updating-mysql-whats-wrong-here/ Share on other sites More sharing options...
andrewgauger Posted May 10, 2010 Share Posted May 10, 2010 else if -> elseif no space Link to comment https://forums.phpfreaks.com/topic/201196-help-me-validating-form-then-updating-mysql-whats-wrong-here/#findComment-1056169 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.