Nov 21, 2009

Php In Echo

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Php In Echo

HannahI
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:
CODE
<?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>
';
?>

Comment/Reply (w/o sign-up)

mastercomputers
Hi HannahI,

CODE
<?php
error_reporting(E_ALL | E_STRICT);
ob_start();
$redirectURL = 'http://www.google.com/';
?>
<form 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>
<?php
if(!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

 

 

 


Comment/Reply (w/o sign-up)

HannahI
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. biggrin.gif

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Php Echo


    Looking for Php, In, Echo

See Also,

*SIMILAR VIDEOS*
Searching Video's for Php, In, Echo
advertisement



Php In Echo

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com