Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: making an url with text and buttons?

  1. #1
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default making an url with text and buttons?

    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.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    $url = 'http://'.$_POST['name'].':'.$_POST['pass'].'@my.com';
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    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.
    Last edited by BLiZZaRD; 01-19-2008 at 07:06 PM.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    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 Code:
    <?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">&nbsp;</div>

                    <div class="form_field">
                    <strong>Password:</strong>
                    <input type="password" id="pass">
                    </div>

                    <div class="clearthis">&nbsp;</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?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    what kind of item? image, frames ... do you have a link?
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  6. #6
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    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/pa...sProtected.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.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <?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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Twey View Post
    Code:
    <?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?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #9
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Quote Originally Posted by BLiZZaRD View Post
    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. 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.

    Code:
    header(sprintf('Location: http://%s:%s@my.com/page/', $_POST['username'], $_POST['password']));
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  10. #10
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    HTML Code:
    <?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">&nbsp;</div>
    
                    <div class="form_field">
                    <strong>Password:</strong>
                    <input type="password" id="pass">
                    </div>
    
                    <div class="clearthis">&nbsp;</div>
    
                    <div class="form_field">
                    <input type="image" src="/images/loginBtn.gif" class="button">
                    </div>
    
                </form>
    <?php } ?>
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •