SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict mari's Avatar
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy $_RESQUEST in php4

    Hello

    i have a server that has only php3 and php4 running and i have a contact form script, but its not recognizing $_REQUEST, and because i have tested the script on a server that is running php5 i have figured out that the php4 is the problem

    how do i get this script to work in php4

    PHP Code:
    <?
    Error_Reporting
    (E_ALL & ~E_NOTICE);

    while (
    $request current($_REQUEST)) {
    if (
    key($_REQUEST)!='recipient') {
    $pre_array=split ("&777&"$request);
    $post_vars[key($_REQUEST)][0]=$pre_array[0];
    $post_vars[key($_REQUEST)][1]=$pre_array[1];
    }
    next($_REQUEST);
    }



    reset($post_vars);
    $subject="From ".$post_vars['your_name'][0] ;
    $headers"From: ".$post_vars['your_email'][0] ."\n";
    $headers.='Content-type: text/html; charset=iso-8859-1';
    $message='';
    while (
    $mess current($post_vars)) {
    if ((
    key($post_vars)!="i") && (key($post_vars)!="your_email") && (key($post_vars)!="your_name")) {

    $message.="<strong>".$mess[1]."</strong>&nbsp;&nbsp;&nbsp;".$mess[0]."<br>";
    }
    next($post_vars);
    }

    mail($_REQUEST['recipient'], $subject"
    <html>
    <head>
    <title>Contact letter</title>
    </head>
    <body>
    <br>
    "
    .$message."
    </body>
    </html>" 
    $headers);
    echo (
    "Your message was successfully sent!");

    ?>
    <script>
    resizeTo(300, 300);
    </script>
    this is the error i get when running it on php3 and php4
    Warning: Variable passed to current() is not an array or object in /sites/contact.php on line 4

    Warning: Variable passed to reset() is not an array or object in /sites/contact.php on line 15
    Your message was successfully sent!

    the message doesn't get sent by the way

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Addict mari's Avatar
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    not sure it just says php4 it has to be php version issue because the same code executes perfectly on php5 server

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Well $_REQUEST was introduced in PHP 4.1
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Member
    Join Date
    Feb 2009
    Location
    Ames, IA
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that's right.

  6. #6
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried using $_POST or $_HTTP_POST_VARS instead of $_REQUEST?

  7. #7
    SitePoint Addict mari's Avatar
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spiderling View Post
    Have you tried using $_POST or $_HTTP_POST_VARS instead of $_REQUEST?
    yeh both still give me the same error

  8. #8
    SitePoint Addict mari's Avatar
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spiderling View Post
    Have you tried using $_POST or $_HTTP_POST_VARS instead of $_REQUEST?
    edit lol i tried $HTTP_POST_VARS again and it works, lol i swear i tried that before i posted this thread and it didnt work, but i think i may have forgot to replace one of the $_REQUEST's somewhere in the code

    anyways thanks, issue solved


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
  •