Here is a script that i would like to use for redirection:
<form id="form1" method="post" action="http://yahoo.com">
<script language="javascript" type="text/javascript">
 document.getElementById('form1').submit();
</script>
</form>
Now I have to control it with a php code, but this one doesn't work:
 $redirect = '<form id="form1" method="post" action="http://google.com">
 <script language="javascript" type="text/javascript">
 document.getElementById('form1').submit();
 </script>
</form>' 
I guess there is a syntax error, but I am unable to figure it out. Please help.
Also let me know is it an ok redirect method that keeps the script execution page as referrer?
2 Answers 2
You are getting the ' wrong inside getElementById
$redirect = '<form id="form1" method="post" action="http://google.com">
 <script language="javascript" type="text/javascript">
 document.getElementById("form1").submit();
 </script>
</form>' 
By the way, this is a unusual way of doing the redirect. Why not use window.location.href instead?
Or a PHP header redirect?
header("Location: http://www.google.com/");
2 Comments
Try this, you need to escape single quotes
$redirect = '<form id="form1" method="post" action="http://google.com"> <script language="javascript" type="text/javascript">
document.getElementById(\'form1\').submit(); </script></form>';
Comments
Explore related questions
See similar questions with these tags.
<?php header('Location: http://www.google.com/'); ?>