Forum Home
Press F1
 
Thread ID: 43524 2004-03-17 09:17:00 Off Topic: Any PHP/MYSQL gurus out there?? prayingmantis (5416) Press F1
Post ID Timestamp Content User
223308 2004-03-26 10:02:00 Sorry had a typo in the above,

foreach($_POST as $key=>$val)

also I forgot the [/b] closing tag in the other script.


Noel Nosivad
Noel Nosivad (389)
223309 2004-03-26 10:05:00 Another mistake I noticed is

[b] wasn't correct.


Noel Nosivad.

This thread is getting quite big and hard to follow don't you think?
Noel Nosivad (389)
223310 2004-03-26 10:15:00 I will try the above in a few secs :)

> Another mistake I noticed is
>
> [b] wasn't correct.

According to Macromedia Dreamweaver MX, which I am using to build this with

Bold = [b] that is correct according to Macromedia Dreamweaver MX

> This thread is getting quite big and hard to follow
> don't you think?

Yep :D
prayingmantis (5416)
223311 2004-03-26 10:26:00 :( With the above fix I am now getting this error:

Parse error: parse error, unexpected '{' in c:\program files\apache group\apache\htdocs\form.php on line 59

Line 59 is: {

Here is the update bit:

<?php
unset($_POST['submit']); //removes submit field from posted vars
foreach($_POST as $key=>$val) //loops through each posted var once
{
if(!$val) //captures empty fields as well as 0
(zero)
{
$notall = 1; //sets the variable suggesting empty y field
}
}
if($notall == 1)
{
echo "Please fill out all fields"; //displays the error message if fields are not filled out
//exit(); //exits the PHP script, no more processing script
}
?>

Any ideas??? ?:|
prayingmantis (5416)
223312 2004-03-26 14:04:00 Hey prayingmantis,

Is that the whole code?

Make sure that unset($_POST['???']); where ??? is the name of the submit fieldname. e.g. if you wrote <input type="submit" value="Submit" name="submit"> then name = submit is the name of the $_POST['submit'];

Remove the comments, they wrap onto the next line so it's hard seeing a problem other that (zero) should be in the comment.


Noel Nosivad

Make sure the script is as exact as the one I posted as that is definitely correct, you can comment out exit() if you want, that won't affect anything apart from the script continues to run all the rest of the code.
Noel Nosivad (389)
223313 2004-03-27 05:05:00 > Is that the whole code?

Yep, that is every thing that I coped (below is the code again)

> Make sure that unset($_POST['???']); where ??? is the
> name of the submit fieldname. e.g. if you wrote
> <input type="submit" value="Submit" name="submit" >
> then name = submit is the name of the
> $_POST['submit'];

Yep, that is correct, I even change the VALUE
<input type="submit" VALUE="submit" > from add to submit, & that did not do any thing.

> Make sure the script is as exact as the one I posted
> as that is definitely correct

Yep, I coped & pasted it strait out of the above post, I even tried it again & I get the same error message:

Parse error: parse error, unexpected '{' in c:\program files\apache group\apache\htdocs\form.php on line 59

Can you e-mail me it? (Just in case it is the forum software which might be adding something to it??), default_xp [at] yahoo [dot] com [dot] au

Here is that bit again:

<?php
unset($_POST['submit']); //removes submit field from posted vars
foreach($_POST as $key= > $val) //loops through each posted var once
{
if(!$val) //captures empty fields as well as 0
(zero)
{
$notall = 1; //sets the variable suggesting empty y field
}
}
if($notall == 1)
{
echo "<font color=#FF0000 > Please fill out all fields</font > "; //displays the error message if fields are not filled out
//exit(); //exits the PHP script, no more processing script
}
? >

any ideas?
prayingmantis (5416)
223314 2004-03-27 05:09:00 > Remove the comments, they wrap onto the next line so
> it's hard seeing a problem other that (zero) should
> be in the comment.

Ah HA! :) That was the problem! YE HA it works YA!!!!! :) :D B-)
prayingmantis (5416)
223315 2004-03-27 08:07:00 Hey prayingmantis,

Good to see you got that sorted.

If you want a better method for checking empty fields, read the PHP Manual on ereg, regular expressions. (!$variable) checks for empty strings and NULL as well as having just a single zero, so it's not good for validating information but it's ok in this case, but you really want to check anything that a user has to input because this is where the security lies.

This way if you use ereg you can specify what characters can be used or not used e.g. 0-9 or A-Za-z, that way they can't put in incorrect characters, as well as setting the minimum limit they can enter, and the maximum limit.


Noel Nosivad
Noel Nosivad (389)
223316 2004-04-15 04:59:00 Hello Noel Nosivad :)

Sorry to bump this back up, but I just have one more question, if you don’t mind helping me with it?

Seen now get a error message If my boss miss out a required field, now I am wondering, how would I add a Thank you message, to tell him that all the info got submitted?
prayingmantis (5416)
223317 2004-04-18 12:15:00 ** Bump :)** prayingmantis (5416)
1 2 3 4 5