View Full Version : making an url with text and buttons?
BLiZZaRD
01-19-2008, 05:12 PM
It is sort of like a log in, only umm.. not?
The idea: two text input boxes and a single button. You enter the text in the two text boxes and are taken to a web page.
Catch: The URL has to contain both texts (say username and password) separated by a colon and BEFORE the domain with an @ sign.
so it looks like:
Username:
Password:
click here button.
You enter "name" and "1pass" and are taken to:
http://name:1pass@thesite.com
I know it is possible, I just can't get my " ."$var" ." in the right order (never understood how those spaces and dots worked).
Thanks for any help.
djr33
01-19-2008, 05:28 PM
$url = 'http://'.$_POST['name'].':'.$_POST['pass'].'@my.com';
BLiZZaRD
01-19-2008, 05:43 PM
Awesome! Thanks for that!
Now.. know anywhere that can explain the use of dots and quotes and spaces in a string? I haven't ever found anything that makes sense to me.
BLiZZaRD
01-19-2008, 06:25 PM
Okay, I am doing something really wrong here (besides working on 5 projects at once). I have tried numerous ways, and once I got to go to the page, but it asked me for the username and password like 12 times (once for each item of the new page that loaded!)
the current set up is like this:
<?php
$url = 'http://'.$_POST['name'].':'.$_POST['pass'].'@my.com';
?>
//html head and body and css stuff...
<form action="<?php $url; ?>" method="post">
<div class="form_field">
<strong>Username:</strong>
<input type="text" id="name">
</div>
<div class="clearthis"> </div>
<div class="form_field">
<strong>Password:</strong>
<input type="password" id="pass">
</div>
<div class="clearthis"> </div>
<div class="form_field">
<input type="image" src="/images/loginBtn.gif" class="button">
</div>
</form>
</body>
</html>
Obviously this doesn't work, and having to enter the pass 12+ times isn't going to work either.. what am I doing wrong?
Master_script_maker
01-19-2008, 06:57 PM
what kind of item? image, frames ... do you have a link?
BLiZZaRD
01-19-2008, 07:09 PM
ermm.. just going to a new page. Nothing fancy.
no frames, no nothing, just 2 text boxes sitting on a page, with a button image to click on.
The page taken to has .htaccess protection.
you can bypass the .htaccess pop up if you have the correct username and password and enter the url like such: http://username:password@site.com/pageThatsProtected.php
Issue is I want the username and password entered on the previous page, and when button is clicked visitor is take to page with url as shown above.
Nothing more to it than that. Really.
<?php header(sprintf('Location: http://%s:%s@my.com/page/', $_POST['username'], $_POST['password'])); ?>
Now.. know anywhere that can explain the use of dots and quotes and spaces in a string?Uh... quotes surround a string, dots join strings. Spaces are irrelevant.
BLiZZaRD
01-19-2008, 08:38 PM
<?php header(sprintf('Location: http://%s:%s@my.com/page/', $_POST['username'], $_POST['password'])); ?>
Umm.. how does that work into my form? I tired various spots nothing worked for me... I don't get it. (I really need to learn php)
Uh... quotes surround a string, dots join strings. Spaces are irrelevant.
that's what a stupid dot does? And if spaces don't matter, how come if I have something like ' . ' whaterver' . ' and I remove a space (as done on accident before) it made a parse error?
thetestingsite
01-19-2008, 08:59 PM
Umm.. how does that work into my form? I tired various spots nothing worked for me... I don't get it. (I really need to learn php)
This part is just saying to do a header redirect to the location http://$_POST['username']:$_POST['password']@my.com/page/ just in the form of sprintf (http://php.net/sprintf). Basically, the %s is a string that is passed through the sprintf method. The first %s is the username and the second is the password. For a better picture, look at the colored code below.
header(sprintf('Location: http://%s:%s@my.com/page/', $_POST['username'], $_POST['password']));
Hope this helps.
Master_script_maker
01-19-2008, 09:04 PM
<?php
if ($_POST['name'] && $_POST['pass']) {
$url = 'http://'.$_POST['name'].':'.$_POST['pass'].'@my.com';
} else { ?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<div class="form_field">
<strong>Username:</strong>
<input type="text" id="name">
</div>
<div class="clearthis"> </div>
<div class="form_field">
<strong>Password:</strong>
<input type="password" id="pass">
</div>
<div class="clearthis"> </div>
<div class="form_field">
<input type="image" src="/images/loginBtn.gif" class="button">
</div>
</form>
<?php } ?>
thetestingsite
01-19-2008, 09:20 PM
A couple of things wrong with that one, "id" should be "name":
<?php
if ($_POST['name'] && $_POST['pass']) {
$url = 'http://'.$_POST['name'].':'.$_POST['pass'].'@my.com';
} else { ?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<div class="form_field">
<strong>Username:</strong>
<input type="text" id="name">
</div>
<div class="clearthis"> </div>
<div class="form_field">
<strong>Password:</strong>
<input type="password" id="pass">
</div>
<div class="clearthis"> </div>
<div class="form_field">
<input type="image" src="/images/loginBtn.gif" class="button">
</div>
</form>
<?php } ?>
Hope this helps.
BLiZZaRD
01-20-2008, 02:39 PM
Thanks thanks thanks. I will look into the sprintf thing in a bit. I really need to get on and learn this language. So much to do so much to do.
This part is just saying to do a header redirect to the location http://$_POST['username']:$_POST['password']@my.com/page/ just in the form of sprintf. Basically, the %s is a string that is passed through the sprintf method. The first %s is the username and the second is the password. For a better picture, look at the colored code below.
Aye, thanks for that, it is a new one to me, but I shall look at it :)
BLiZZaRD
01-22-2008, 03:17 PM
You know what? I used every example in this thread, most of them twice... and I couldn't get any of them to work! :(
I am going to try again in a little bit, and if I can't do it I will post a link to a page with text areas showing the php used and maybe someone can see what I am doing wrong...
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.