SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: php form issue

  1. #1
    Non-Member
    Join Date
    Jun 2008
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php form issue

    I have a submission form that has a url input. What i dont know is that how can i retrieve a url with REQUEST_URI or QUERY_STRING (www site com/index php?this=asdfas&that=asdfa)

    Im thinking thats a problem because upon form submission, inputs will be put into strings, so if the url in the url input contains strings itself, will it mess up the server readings. Sorry i havent tested myself before asking, because i am 70% sure it will.

    Do you guys have any solutions? Im trying to insert the form input information into mysql without any conversion. So the url input is my only problem on the form here.

    thanks.

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the name attribute value is "this" then $_GET['this']. Though I'd advise POST.
    Cross browser css bugs

    Dan Schulz you will be missed

  3. #3
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,782
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    If the information you are posting are private information you should be using the POST method as Scratchy said.
    If I understand you right you want to know how to read the ?this=adsfs

    $dfsf=$_GET['this'];
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  4. #4
    Non-Member
    Join Date
    Jun 2008
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for not making myself clear.

    I know how to retrieve form information with post and $_get['this'] but, what i am saying is how do i get this information

    <form action=./validate php>
    inputs

    Name: test
    Last: test2
    URL: www site com/index php?code=fasdf&more=awea4

    </form>


    therefore will be like this when the form is submitted

    www site com/validate php?name=test&last=test2&url=www site com/index php?code=fasdf&more=awea4

    so what im saying is that its an url string with another url with string (string within string)

    im afraid that the server will return an error because a string variable contain the url with more strings variable.

  5. #5
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,782
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    I'd put the base URL in there and store the others in different GET parts and then concentate the string into 1 variable.
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  6. #6
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure if I understand you... but have you actually tried it?

    The query string will be URL-encoded so it will work just fine.
    Last edited by decowski; Feb 12, 2009 at 14:31.

  7. #7
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,782
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Code php:
    <?php
    $name=$_GET['name'];
    $this=$_GET['this'];
     
    $combined="http://www.sitehere.com/?name=".$name."&this=".$this";
    ?>

    Something like that?
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  8. #8
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The OP is talking about a form here Ryan, not inside-PHP.

    Decowski is correct. The url will be uri-encoded, so you will, infact, see:

    Code:
    http://www.site com/validate.php?name=test&last=test2&url=http&#37;3A%2F%2Fwww.site.com%2Findex.php%3Fcode%3Dfasdf%26more%3Dawea4&more=evenmore
    If you were to link this through PHP, you would run it through urlencode() before placing it in the final url, e.g. if you had a link generating application:
    PHP Code:
    <?php
    $Url 
    $_GET['Url'];
    $GeneratedUrl sprintf('http://www.yoursite.com/url.php?url=%s&more=evenmore'urlencode($Url));
    printf('<a href="%2$s" title="%1$s">%1$s</a>'$Url$GeneratedUrl);
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  9. #9
    Non-Member
    Join Date
    Jun 2008
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh yes that's right, thank you all very much.

    I just had the one imagination.

    Sorry i havent tested myself because its a one file with many code that arent sorted in completed order yet so if i was to test i would of had to do alot of commenting to the script to avoid error messages.

    thank you!


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
  •