| | |
limits
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Feb 2008
Posts: 22
Reputation:
Solved Threads: 0
already put the validation..it will prompt user the errors..but it query into database also how can i solved it??
PHP Syntax (Toggle Plain Text)
<table width="1000" height="95" border="1"> <tr> <td bgcolor="#0000FF"> </td> </tr> </table> <?php include("connect.php"); //this is your validation in the form,put it here.... if (empty($_POST['name'])) { $errors[] = 'Please enter a name'; } if (empty($_POST['email'])) { $errors[] = 'Please enter a valid e-mail address'; } else if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_POST['email'])) { $errors[] = 'Please enter a valid e-mail address'; } if (empty($_POST['contact'])) { $errors[] = 'Please enter a valid contact with numeric value'; } else if (!is_numeric($_POST['contact'])) { $errors[] = 'Please enter a valid contact with a numeric value'; } if (empty($_POST['person_attend'])) { $errors[] = 'Please enter some word for person attend'; } else if (strlen ($_POST['person_attend']) > 255) { $errors[] = 'person attend'; } if (empty($_POST['comment'])) { $errors[] = 'Please enter some comment'; } else if (strlen ($_POST['comment']) > 255) { $errors[] = 'comment '; } $name = $_POST['name']; $email = $_POST['email']; $contact = $_POST['contact']; $person_attend = $_POST['person_attend']; $comment = $_POST['comment']; if($name="" && $email="" && $contact="" && $person_attend="" && $comment="" ) $name = $_POST['name']; $email = $_POST['email']; $contact = $_POST['contact']; $person_attend = $_POST['person_attend']; $comment = $_POST['comment']; $query = "INSERT INTO rsvp (id, name, email, contact, person_attend, comment) VALUES ('', '$name', '$email', '$contact', '$person_attend', '$comment')"; $results = mysql_query($query) or die ("Could not execute query : $query." . mysql_error()); { if(isset($errors)) { foreach($errors as $val) { echo "Error: $val <br>"; } } { echo "Thanks for join us."; } } { mysql_close(); } ?> <a href="Index.php">View list attend</a>
Try this.
One suggestion. Look at how loops, conditions, { } works. You have { } all over the place.
php Syntax (Toggle Plain Text)
<table width="1000" height="95" border="1"> <tr> <td bgcolor="#0000FF"> </td> </tr> </table> <?php include("connect.php"); //this is your validation in the form,put it here.... if (empty($_POST['name'])) { $errors[] = 'Please enter a name'; } if (empty($_POST['email'])) { $errors[] = 'Please enter a valid e-mail address'; } else if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_POST['email'])) { $errors[] = 'Please enter a valid e-mail address'; } if (empty($_POST['contact'])) { $errors[] = 'Please enter a valid contact with numeric value'; } else if (!is_numeric($_POST['contact'])) { $errors[] = 'Please enter a valid contact with a numeric value'; } if (empty($_POST['person_attend'])) { $errors[] = 'Please enter some word for person attend'; } else if (strlen ($_POST['person_attend']) > 255) { $errors[] = 'person attend'; } if (empty($_POST['comment'])) { $errors[] = 'Please enter some comment'; } else if (strlen ($_POST['comment']) > 255) { $errors[] = 'comment '; } $name = $_POST['name']; $email = $_POST['email']; $contact = $_POST['contact']; $person_attend = $_POST['person_attend']; $comment = $_POST['comment']; if($name="" && $email="" && $contact="" && $person_attend="" && $comment="" ) { if(isset($errors)) { foreach($errors as $val) { echo "Error: $val <br>"; } } } else { $name = $_POST['name']; $email = $_POST['email']; $contact = $_POST['contact']; $person_attend = $_POST['person_attend']; $comment = $_POST['comment']; $query = "INSERT INTO rsvp (id, name, email, contact, person_attend, comment) VALUES ('', '$name', '$email', '$contact', '$person_attend', '$comment')"; $results = mysql_query($query) or die ("Could not execute query : $query." . mysql_error()); echo "Thanks for join us."; mysql_close(); } ?> <a href="Index.php">View list attend</a>
One suggestion. Look at how loops, conditions, { } works. You have { } all over the place.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- Internet Explorer Message (Web Browsers)
- Tell us about yourself! (Community Introductions)
- another newbie with alot of redhat and apache server Q'S (Linux Servers and Apache)
- Limits 10 Per Page (C)
- ALICE Sucks (DaniWeb Community Feedback)
- Mounting an ext2 Linux Filesystem in Windows XP/NT/2000 (*nix Hardware Configuration)
- strange annoying errors (Windows NT / 2000 / XP)
- Freezing (Troubleshooting Dead Machines)
- Amount of space for backup limited by Windows (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: Comment Box
- Next Thread: Tearing my hair out
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions simple sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube






