Jump to content

[SOLVED] ampersands


fou2enve

Recommended Posts

I have a login page that posts to itself along with a url attached (ie login.php?url=protectedpage.php?ID=9230&B=4949 ). the problem I'm having is getting anything after the & to stick. Here's what i mean:

 

 

if (isset($_POST['name']) || isset($_POST['pass'])) {
    // form submitted
    // check for required values
    if (empty($_POST['name'])) {
        die ("ERROR: Please enter username!");
    }
    if (empty($_POST['pass'])) {
        die ("ERROR: Please enter password!");
    }

    if ($password="password") {
        // if a row was returned
        // authentication was successful
        // create session and set cookie with username
        session_start();
        $_SESSION['auth'] = 1;
        setcookie("username", $_POST['name'], time()+(60*5));
        echo "Access granted!";
	$url = (isset($_GET['url'])) ? "$_GET['url']" :'index.php';
    echo "<meta http-equiv=".'"'.'refresh'.'"'.' content="'."12;url=$url".'">';
echo $url;
    }
    else {
        // no result
        // authentication failed
        echo "ERROR: Incorrect username or password!";
    }
    

}
else {
    // no submission
    // display login form
?>
    <html>
    <head></head>
    <body>
    <center>
    <form method="post" action="login.php?url=<? echo $url; ?>">
    Username <input type="text" name="name" value="AuthorizedUser">
    <p />
    Password <input type="password" name="pass">
    <p />
    <input type="submit" name="submit" value="Log In">
    </center>
    </body>
    </html>
<?php
}

?> 

 

im using $url=$_GET['url']; to get the URL and then later on in the script echoing $url into a meta refresh after a successful auth (actual auth process uses mysql but i pulled that out for now) but when the outputs i get: protectedpage.php?ID=9230 nothing else. I've tried using %26 in the initial url but that didnt help. I tried suing str_replace to try and replace & with %26 right before it outputted, but that didn't work. :-\

 

 

ideas?

Link to comment
https://forums.phpfreaks.com/topic/52878-solved-ampersands/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.