PHP submit button not working right -
<div class="contact-forum"> <h1>contact forum</h1> <div class="contact-enters"> <form action="home.php" method="post"> <div class="firstname"> <p>first name:</p> </div> <input type="text" name="firstname" placeholder="firstname" /> <br /> <div class="lastname"> <p> lastname: </p></div> <input type="text" name="lastname" placeholder="lastname" /> <br /> <div class="email"> <p> email: </p></div> <input type="text" name="email" placeholder="e-mail" /> <br /> <div class="topic"> <p>topic: </p> </div><input type="text" name="topic" placeholder="topic" /> <br /> <div class="message"> <p> message: </p> </div> <div class="message-box"><input type="text" name="message" /></div> <br /> <input type="submit" name="send" /> </form> </div> </div> <div class="php"> <?php $con = mysqli_connect("localhost", "kylelongrich", "cash7144") or die('can not connect server'); mysqli_select_db($con,"kylelongrich") or die("could not connect database"); if(isset($_post['send'])) { $firstname = strip_tags($_post['firstname']); $lastname = strip_tags($_post['lastname']); $email = strip_tags($_post['email']); $topic = strip_tags($_post['topic']); $message = strip_tags($_post['message']); $email_query = mysqli_query($con,"select email emailquestions email ='$email'") or die("could not check email"); $count_email = mysqli_num_rows($email_query); if ($count_email > 0) { echo 'your email alread in use'; } $sql = "insert emailquestions (firstname, lastname, email, subject, message) values ('$firstname','$lastname','$email','$topic','$message')"; mysqli_query($con, $sql); $message = 'your message has been sent'; } $message=''; ?>
when being displayed submit button when hit won't send or work @ all. no php code errors come not work properly. because of the styling? great
try else after if statement, , use set in query.
if ($count_email > 0) { echo 'your email alread in use'; } else { $sql = "insert emailquestions set (firstname, lastname, email, subject, message) values ('$firstname','$lastname','$email','$topic','$message')"; mysqli_query($con, $sql); $success_message = 'your message has been sent'; echo $success_message; }
hope helps
Comments
Post a Comment