Jump to content
xisto Community
Sign in to follow this  
HannahI

Php In Echo

Recommended Posts

Hello,
I have a PHP script for a login.
It is a standard script I've written.
My problem is that I can't get the redirect variable into the echo statment.
This doesn't work:

<?php$redirctURL = "http://google.com";echo '<form action=" ' . $redirctURL . ' " method="post">Username:<input type="text" name="username"> <br />Password:<input type="password" name="password"> <br /></form>';?>

Share this post


Link to post
Share on other sites

Hi HannahI,

 

<?phperror_reporting(E_ALL | E_STRICT);ob_start();$redirectURL = 'https://www.google.com/&%2339 action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="window.location.href=<?php echo $redirectURL; ?>;">  <fieldset>	<legend>Login Form</legend>	<ul>	  <li><label for="username">Username:</label> <input id="username" name="username" type="text" /></li>	  <li><label for="password">Password:</label> <input id="password" name="password" type="password" /></li>	</ul>	<input id="login" name="login" type="submit" value="Login" />  </fieldset></form><?phpif(!empty($_POST['login']) && $_POST['login'] === 'Login') {  header('Location: ' . $redirectURL);}ob_end_flush();?>

Hope this is what you're looking for?

 

I don't understand why you would use the action as a redirect, action is suppose to point to the forms processor, not to redirect a page.

 

 

Cheers,

 

 

MC

Share this post


Link to post
Share on other sites

Thanks, mastercomputers.The main reason that I needed it is so I could pass on a variable to the program for a login and if it doesn't I would get I would get a standard login page. :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.