small help related to php

This is a discussion on small help related to php within the Tech Board forums, part of the Community Boards category; I am using html hidden input elements to keep information between pages but when i transfer the values with the ...

  1. #1
    Registered User Akhil's Avatar
    Join Date
    Feb 2003
    Posts
    14

    small help related to php

    I am using html hidden input elements to keep information between pages but when i transfer the values with the FORM tags using POST method, I loose the bit of information after spaces.

    ie,
    page 1 TAKES IN USER DETAILS: NAME, AGE AND SO ON.....from user
    (for ex: take name "harley davidson" as user input)


    I USE POST METHOD TO TRANSFER IT TO AN INTERMEDIATE PAGE....page 2 where it shows these details to user..and here the name is shown properly as harley davidson when i use $_POST[name];

    BUT i need to transfer these details onto page 3 where another operation is carried out but when i use html form element such as <input type=hidden name=$_POST[fname]> and then again use POST method...


    on the page 3 i get output as only harley and i tend to loose the remaining after the spaces...

    anyways to sort this issue out..

    thanks in advance

  2. #2
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    2 things with this thread.

    1: This isn't a Windows-specific problem (more Linux, but it should be put in the General or Tech. forum).

    2: I don't understand what you're saying completely. Can you show code?

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,260
    Try:
    Code:
    <input type=hidden name=\"$_POST[fname]\">

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Actually you'd want something like:
    PHP Code:
    echo "<input type='hidden' name='$_POST[fname]' />"

  5. #5
    Registered User Akhil's Avatar
    Join Date
    Feb 2003
    Posts
    14

    cheers

    tried that bithub..and it just worked..


    thanks a lot..saved me the trouble of looking around...



    and i do apologize for posting this in the wrong forum..

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,260
    no worries. We don't have a web programming forum, so it may not be clear for people on where to post.

  7. #7
    Registered User
    Join Date
    Nov 2004
    Location
    Slovenia, Europe
    Posts
    115
    Quote Originally Posted by Thantos
    Actually you'd want something like:
    PHP Code:
    echo "<input type='hidden' name='$_POST[fname]' />"
    It's better to use double-quotes in HTML, so you must addslash quotes....
    [C++]
    IDE: DevC++ 4.9.9.2 (GCC 3.4.2)
    2nd compiler: g++ (GCC 3.4.3/4.0.0)
    3rd compiler: Borland 5.5
    [C#]
    IDE: Microsoft Visual C# Express 2005
    2nd IDE: SharpDevelop
    2nd compiler: csc in Command Prompt
    .NET Framework: 2.0
    [PHP]
    Core: 5.1.0 beta 3
    IDE: PHPEdit
    2nd IDE: Notepad
    Favourite extensions: exif,gd2,mysql
    Favourite PEAR packages: DB, XML_RSS, ID3
    Favourite databases: SQLite, MySQL

  8. #8
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    >>It's better to use double-quotes in HTML

    FYI it's not neccessarily a language specific practice, it's usually a good idea to start out with double quotes so that you can nest single quotes...it could also be done the other way around but it's just one of those syntax things that people try to agree upon.
    PHP and XML
    Let's talk about SAX

  9. #9
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    Quote Originally Posted by Waldo2k2
    >>It's better to use double-quotes in HTML

    FYI it's not neccessarily a language specific practice, it's usually a good idea to start out with double quotes so that you can nest single quotes...it could also be done the other way around but it's just one of those syntax things that people try to agree upon.
    It's actually just a W3C standard, just like using <br /> instead of <br>.


    Anyways, here's something you can do.

    page1.php:
    PHP Code:
    <form action="page2.php" method="POST">
    Name: <input type="text" name="name"><br />
    <
    input type="submit" name="sub" value="Submit" />
    </
    form
    page2.php:
    PHP Code:
    $name = $_REQUEST["name"]; // I always use request (it accepts either POST or GET statements)

    <form action="page3.php" method="POST">
    Name: <? echo $name?><br />
    <input type="hidden" name="name" value="<? echo($name); ?>" />
    <input type="submit" name="sub" value="Submit" />
    </form>
    page3.php:
    PHP Code:
    $name $_REQUEST["name"];

    // enter whatever you have to do here, like...
    echo("Hello "$name ."!"); 
    I think it'd be easier to do combine the purpose of page1 & page2 together (so that page1 lets the user input stuff, and after submitting it, display for confirmination [?]). This is actually VERY simple. If you need any help, just PM me or something.

  10. #10
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by publikum
    It's better to use double-quotes in HTML, so you must addslash quotes....
    You care to back up your claim? I have yet to see anything in the W3 standards saying to use double quotes over single quotes.

  11. #11
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    I wouldn't worry about it thantos, it's a good practice to get into. I think most people use double quotes and nest the singles. oh well...I doubt that the w3c would put something like that as a standard considering there are several different ways to format code anyway.
    PHP and XML
    Let's talk about SAX

  12. #12
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    I can't remember the last time I had nested quotes in my outputted HTML code. You care to share an example because looking at my pages I don't see an example off hand.

    Now in my php code I have nested quotes all the time and I switch back and for between ' and " for the outer quote depending on what I need to do.

    Quote Originally Posted by Quantrizi
    It's actually just a W3C standard, just like using <br /> instead of <br>.
    Actually that depends on the particular standard you are using. IIRC HTML 4.0 doesn't require <br/> but XHTML 1.0 requires that all tags be closed.

    Also do you realize Quantrizi that your
    PHP Code:
    $name = $_REQUEST["name"]; // I always use request (it accepts either POST or GET statements) 

    <form action="page3.php" method="POST"> 
    Name: <? echo $name?><br /> 
    <input type="hidden" name="name" value="<? echo($name); ?>" /> 
    <input type="submit" name="sub" value="Submit" /> 
    </form>
    has several problems:
    1) your first statement isn't inside a php block
    2) not all servers support short tags (should be <?php )

    publikum if you are going to make a claim and give a rep hit for it at least be able to back up your claim.

    I have yet to see any proof that " are better then ' in HTML.
    Last edited by Thantos; 01-24-2005 at 07:28 PM.

  13. #13
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    actually I usually run into nested when i output javascript and html to the page with php...I could grab an example when I get back from class if you want.
    PHP and XML
    Let's talk about SAX

  14. #14
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Please, because I can't see that being nested quotes in the actual html.

  15. #15
    </life>
    Join Date
    Oct 2004
    Posts
    83
    I dont think it really matters, its down to personal preference and the outcome is the same.
    Microsoft is merely an illusion, albeit a very persistant one.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doxygen failing
    By Elysia in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 04-16-2008, 02:24 PM
  2. PHP installation
    By ssharish2005 in forum Tech Board
    Replies: 8
    Last Post: 11-23-2007, 09:42 PM
  3. want to make this small program...
    By psycho88 in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2005, 02:05 AM
  4. PHP on my Computer!
    By xxxrugby in forum Tech Board
    Replies: 4
    Last Post: 03-15-2005, 09:34 AM
  5. PHP 4.3.0 released
    By codingmaster in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-30-2002, 07:40 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21