Help please!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wafasn
Forum Newbie
Posts: 6
Joined: Tue Apr 06, 2004 11:10 am

Help please!

Post 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.
Last edited by wafasn on Tue Apr 06, 2004 11:39 am, edited 1 time in total.
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post 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
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

Or you could do a form validation script in javascript
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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;
 }

?>
Post Reply