Jump to content

Recommended Posts

I have a form as below:

 

<form name="" method="POST" action="frozenaccountprocess.php?ID=<?=$ID?>" id="Form1" onsubmit="return ValidateForm1(this)">
<textarea name="TextArea1" rows="10" cols="55"></textarea><br><br>
<input type="submit" name="Submit" value="Submit Response"><br><br><br>
</form>

 

Then on frozenaccountprocess.php i have put:

<?php
If(isset($_POST['Submit'])){
echo 'test1';
}Else{
echo 'test2';
}
?>

 

but i keep getting test2 echo'd rather than test1... why is that what did i do wrong ?1

Link to comment
https://forums.phpfreaks.com/topic/85829-solved-form-isset-wont-work/
Share on other sites

looks to me like it calls a custom fuction to validate the fields (function named "ValidateForm1")

 

If it returns True, the form is submitted. If it returns False, the form will not be submitted.

 

It was probably returning False or just creating an error and breaking your form.

The onsubmit handle was calling a javascript function when the form is about to be submitted. It looks like the function was meant to check the form was filled in properly and then either stop the form submitting (if the form was filled out incorrectly) or allow the form to submit normally. You presumably didn't have that function defined and so it was always returning false and therefore not submitting.

Oh i see why now. Some one was helping me with forms and i told him i was going to add JS validation later on so he must of put that tag into the form attribute for me to deal with later on. I then changed my mind cos people can turn JS off so was wasted time coding. Then just assumed that onsubmit was part of html lol !

 

Thanks for the help though guys!

Yeah people can turn it off but most either don't know how or just don't. Either way, the javascript validation is good for useability as people can be told of slight errors without having to load another page, be told that there were errors and they go back and change them. You shouldn't rely on javascript to do your validation for you though. Validate with javascript and PHP if you can.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.