Small Help

Hey everybody !
I haven’t coded in PHP for years, now I wanted to get back and I started to make some basic Wargames.
But for some reason,when people click the Submit button nothing happens.
Check the code.
Form Area:

<p><input type="password" name="pwdfield" /> <input type="submit" name="submitbtn" id="submitbtn" value="Submit" />
PHP Area:

[code]<? function validate()
if($_POST[‘pwdfield’] == ‘n3wb13’)
{ echo “good Job cake!”; } else { echo “Start learning from the begginning.”; }

$pwd = $_POST[‘pwdfield’] ;
if (isset($_POST[‘submitbtn’]))
validate ();

You need to use a tag.
e.g. if your script is called test.php and you want to process the submitted data within the same script as the form itself, add this at the start of the form:

and add this at the end:

Also, in your PHP, change this:

$pwd = $_POST[‘pwdfield’] ;
if (isset($_POST[‘submitbtn’]))
validate ();

to this:

if ($_POST) {

A submit button does not submit anything so that line of code won’t work. I removed the $pwd line because you refer to the pwdfield directly in the validate function.

Sponsor our Newsletter | Privacy Policy | Terms of Service