Page 1 of 1

Help please!

Posted: Tue Apr 06, 2004 11:10 am
by wafasn
Hi guys,

I have the following question:

I have a file called displayEvents.php with button called edit which lead when hit to another page called editEvent.php which has a button called save.
my probelm is as follows.

when the button save is hit, I want to check if all fields on page(editEvent.php )are not empty, if no one is empty I save the data in a database table and go to another page(index.php), this works fine but the problem is when some fields are empty, I want to keep the same page loaded and ask user to fill all fields before saving, how can I do this?
thanks in advance.

Clarification:
I use a javascript function to chexk if all the fields are filled the problem is if the event is displayed and if I delete for example the event title and hit save, I go backo top the same page but I can still see the event title there, I want to go back to the same page but with event title field empty.
thanks again.

Posted: Tue Apr 06, 2004 11:12 am
by Deemo
you can check all the values with an if statement and then use header("Location: editEvent.php");

you could also have a get variable or a session variable that you can use to tell the user that they didnt fill them all in

Posted: Tue Apr 06, 2004 11:24 am
by magicrobotmonkey
Or you could do a form validation script in javascript

Posted: Tue Apr 06, 2004 11:27 am
by tim
this is my love script, works well and gives ALL the possible errors if the fields are left blank.

Code: Select all

<?php
if ($name == "") {
   $msg[] = "<br><font color=red>You did not fill-in a username.<br>";
} if (!ereg("^[_a-zA-Z0-9-]+$", $name)) {   
   $msg[] = "<br><font color=red>You did not fill-in a correct username.<br>";
} if ($passw == "") {
   $msg[] =  "<br><font color=red>You did not fill-in a password.<br>";
} if ($email == "") {
   $msg[] ="<br><font color=red>You did not fill-in a email address.  If you dont have one, please enter 'n/a' in the box.<br>";
} if ($aim == "") {
   $msg[] = "<br><font color=red>You did not fill-in a aol screen name.  If you dont have one, please enter 'n/a' in the box.<br>";
} 
foreach($msg as $value) {
   echo $value;
 }

?>