Results 1 to 6 of 6

Thread: PHP Redirect Script

  1. #1
    Join Date
    Jul 2009
    Beans
    2

    PHP Redirect Script

    I have been trying to write a simple php script using html input variables to combine both of them in the user's address bar. My code is as follows:

    PHP Code:
       <?php


    if(isset($_POST['submit'])){

    header('Location: '.$_POST['servoce'].$_POST['num']');


    }
    else{

    echo "
    <form method=\"POST\" ENCTYPE=\"multipart/form-data\">
    <table>
    <tr><td>Tracking Number:</td><td><input type=\"text\" name=\"num\"><br></td></tr>
    <tr><td>Service:</td><td><select name=\"ser\">
    <option value=\"https://fedex.com/mobi/track.do?shipDate=trackingNbr=\">FedEx</option>
    <option value=\"http://mobile.ups.com/ups/-1-3-2;jsessionid=732769EA6CA319415A3400B481B947CB.srv2?a=2.1039004&wi3.1039004.-9999=1Z6874R09023233800\">UPS</option>

    </select></td></tr>

    <tr><td>Tracking Number:</td><td><input type=\"text\" name=\"amo\"><br></td></tr>

    <tr><td></td><td><input type=submit name=submit value=\"Start\"><br><br></td></tr>

    <SCRIPT LANGUAGE=\"JavaScript\" TYPE=\"text/javascript\">
    document.forms[0].num.select()</SCRIPT>
    ";

    }
    }
    ?>
      </div>
    When I test this script I get the return of these parse errors:

    Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/tjoozeyc/public_html/txtdrop/index.php on line 139

    Parse error: syntax error, unexpected '}' in /home/tjoozeyc/public_html/txtdrop/index.php on line 164
    I have tried 2 debug but nothing

  2. #2
    Join Date
    Apr 2009
    Location
    Canada
    Beans
    414
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: PHP Redirect Script

    If I'm not mistaken, that error is caused by you putting 1 to many } at the end of the program.

  3. #3
    Join Date
    Jul 2009
    Beans
    2

    Re: PHP Redirect Script

    I then receive this error after submitting:


    Warning: Cannot modify header information - headers already sent by (output started at /home/tjoozeyc/public_html/txtdrop/index.php:139)

  4. #4
    wojox is offline I Ubuntu, Therefore, I Am
    Join Date
    Apr 2009
    Beans
    8,628

    Re: PHP Redirect Script

    Is this the index page?

    I don't see 139 lines?

  5. #5
    wojox is offline I Ubuntu, Therefore, I Am
    Join Date
    Apr 2009
    Beans
    8,628

    Re: PHP Redirect Script

    Never mind I see your new error

    The "headers already sent" error is usually caused by having white space before or after the opening and closing PHP tags (<?php . . . ?>).

  6. #6
    Join Date
    Jun 2008
    Beans
    11
    Distro
    Ubuntu Development Release

    Re: PHP Redirect Script

    Quote Originally Posted by wojox View Post
    Never mind I see your new error

    The "headers already sent" error is usually caused by having white space before or after the opening and closing PHP tags (<?php . . . ?>).
    Maybe, but if you notice there is a closing div tag at the end, which probably means this code is in the middle of the page, hence the error.

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
  •