Jump to content

pickamaterina

New Members
  • Posts

    6
  • Joined

  • Last visited

pickamaterina's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks I acutally figured it out, and how stupid I was, I should have just typed $result=mysql_query("INSERT....."); its working now thanks everyone !
  2. Damnit, I meant to say to post data from form into database and still use this validation?
  3. Actually the point was to post data in form and also use this validation?
  4. misstyped $result=".." if(mysql_query($result)){ echo "<script type='text.....
  5. well I tried connecting it via if $result=".." (mysql_query($result)){ echo "<script type='text..... and it didn't work... sorry I am just a beginner so I can't think of any way how to connect it and leave that if or use it because it is kinda needed for validation?
  6. <?php $user="root"; $password=""; $database="base"; $host="localhost"; $table="com"; mysql_connect($host, $user, $password) or die("error"); mysql_select_db($database) or die("error"); $name = $_POST['name']; $lastname = $_POST['lastname']; $email = $_POST['email']; $coment= $_POST['coment']; $error = ''; if(empty($name) || empty($lastname) || empty($email) || empty($coment)) { $error .= 'error. '; } if(!preg_match("/^[a-zA-A]+$/i", $name)) { $error .= 'Error '; } if(!preg_match("/^[a-zA-A]+$/i", $lastname)) { $error .= 'Error '; } if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)) { $error .= 'errorl. '; } if(!preg_match("/^[a-zA-z0-9.,?!]+$/i", $comment)) { $error .= 'Error '; } if($error == '') { $result = "INSERT INTO com (name, lastname, email, coment) VALUES('$name', '$lastname', '$email','$coment')"; echo "<script type='text/javascript'>alert('Thanks.'); window.close();</script>";} else{ echo"<script type='text/javascript'>alert ('$error'); window.close(); </script>";} Errors seems to be working its just it won't insert data in table in mysql database.... Thank you so much.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.