1

this bit of code is not working. I am using PHP and want to redirect my user to CAD.HTML after he has submitted his data. Am I missing something obvious here. Please help!

input name="Submit " type="submit" id="Submit " value="Submit Request" onClick="Location:cad.html"

I am beginner and haven't started writing functions please let me know if it is required with some bit of help with the code

Thank you

Update

form id="post" method='post' action="mymail.php" name="post"

input name="Submit " type="submit" id="Submit " value="Submit Request" onClick="location.href=cad.html" />

2
  • "I am using PHP and want to redirect my user to CAD.HTML" -- that example is using js, not PHP Commented May 9, 2011 at 6:14
  • You cannot reliably use JavaScript to redirect after a submit and there is absolutely no need. Redirect in the php only. Commented May 9, 2011 at 6:31

1 Answer 1

1
<form action="process.html" method="GET">
   ... your other inputs here ....

   <input name="Submit" type="submit" id="Submit " value="Submit Request" />
</form>

This is the proper way of creating a form in your html

In your php, you can process the data like

$variable = $_GET['name'];

and to redirect you can use the header function:

header('Location: cad.html');

This might be what you are looking for.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the immediate response Ibrahim but it didn't work. The page does not get redirected
ok i have made an edit now it should work, what are you trying to achieve? are you trying to send some information from one page to another?
Yes Ibrahim I am trying to collect user data send it to another page then redirect him to CAD.html ....I am using POST method
Missing quotes in the onclick. Using a submit to execute a location change is not a great idea either. Delete the first part of the answer and it is correct

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.