SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot arthaus's Avatar
    Join Date
    Jun 2002
    Location
    Pasadena, CA
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mail Form not working w/PHP 4.3

    Hi all,

    Recently we upgraded to PHP 4.3 and I'm having difficulty using my mail form.

    Q: What do I need to change, to make this form work properly?

    PHP Code:
    <?php
    // Enter your email address here
        
    $adminaddress "daa@ours.com"

    // Enter the address of your website here MUST include [url]http://www[/url]. 
        
    $siteaddress ="http://www.filerack.com"

    // Enter your company name or site name here 
        
    $sitename "File Rack"

    // Enter your page title here
        
    $ptitle "IBM 421 Comment Form";

    //Background Color
        
    $bgcolor "#069";

    //Table Border
        
    $bocolor "#069";

    // Font Color
        
    $fcolor "#FFF";

    // Link Color
        
    $lcolor "#FFA800";

    // Font Style
        
    $font "verdana, arial, helvetica, sans-serif";

    // Font Size
        
    $fontsize "-1";
        
    // Font Big
        
    $fontbig "+2";
        
    // Font Big Color
        
    $fontbigcolor "#FFA800";

    // Don't touch this it grabs the date and time from your server
        //$date = date("m/d/Y H:i:s");
        
    $date date("m.j.y h:i a T");
        
    $vers "mail.php";
        
    $traceroute "<a href=\"http://www.above.net/cgi-bin/trace?$REMOTE_ADDR\">";

        if (
    $REMOTE_ADDR == ""$ip "<i> no ip </i>";
            else 
    $ip getHostByAddr($REMOTE_ADDR);

        if (
    $action==""):
    ?>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title><? echo "$ptitle"?></title>

    <link rel="stylesheet" href="form.css" type="text/css">

    <script language="JavaScript">
    <!--
    function alterNate(elm){
        if (!elm.base) elm.base = elm.value
        if (elm.value == elm.base) elm.value = "";
        else if (elm.value == "") elm.value = elm.base;
    }
    //-->
    </script>
    </head>

    <body onLoad="document.validation.fname.focus()">

    <center>
    <form name=validation method=post action="<? echo "$PHP_SELF"?>" onSubmit="return checkbae()"> 
        <table border="0" cellspacing="0" cellpadding="0 " width=80% bgcolor="<? echo "$bocolor"?>"> 
    <tr><td valign="top">

    <center>
        <table border="0" cellspacing="0" cellpadding="5" width=70%  bgcolor="<? echo "$bgcolor"?>"> 
    <tr><td valign="top" colspan=2><font face="<? echo "$font"?>" size="<? echo "$fontbig"?>" color="<? echo "$fontbigcolor"?>"><? echo "$ptitle"?></font></td></tr>

    <tr><td valign="top" colspan="2"><font face="<? echo "$font"?>" size="<? echo "$fontsize"?>" color="<? echo "$fcolor"?>">First Name:</font></td></tr> 
    <tr><td valign="top"><input type="text" class="myinput" name="fname" size="40"></font></td></tr>

    <tr><td valign="top" colspan="2"><font face="<? echo "$font"?>" size="<? echo "$fontsize"?>" color="<? echo "$fcolor"?>">Last Name:</font></td></tr> 
    <tr><td valign="top"><input type="text" class="myinput" name="lname" size="40"></font></td></tr>

    <tr><td valign="top" colspan="2"><font face="<? echo "$font"?>" size="<? echo "$fontsize"?>" color="<? echo "$fcolor"?>">Email Address:*</font></td></tr> 
    <tr><td valign="top"><input type="text" class="myinput" name="vemail" value="required field" onBlur="alterNate(this)" onFocus="alterNate(this)" name="req:Email Address" size="40"></font></td></tr>    

    <tr><td valign="top" colspan="2"><font face="<? echo "$font"?>" size="<? echo "$fontsize"?>" color="<? echo "$fcolor"?>">Telephone Number:</font></td></tr> 
    <tr><td valign="top"><input type="text" class="myinput" name="telno" size="20"></font></td></tr>


    <tr><td valign="top" colspan="2"><font face="<? echo "$font"?>" size="<? echo "$fontsize"?>" color="<? echo "$fcolor"?>">Questions/Comments:</font></td> </tr> 
    <tr> <td valign="top" colspan="2"><textarea name="comments" rows="3"  
    cols="40"></textarea></font></td> </tr> 

    <tr><td colspan=2><input type="submit" name="action" value="Send" class="btn_button">&nbsp;&nbsp;<input type="reset" name="reset" value="Reset!" class="btn_button"><br>

    <tr><td valign="top" colspan="2"><font face="<? echo "$font"?>" size="<? echo "$fontsize"?>" color="<? echo "$fcolor"?>">*Required field.</font></td></tr>

    </form></td> 
    </tr> 
    </table> </center></td></tr> 
    </table>

    <script language="JavaScript1.2">
    var testresults
    function checkemail(){
    var str=document.validation.vemail.value
    var filter=/^.+@.+\..{2,3}$/
    if (filter.test(str))
    testresults=true
    else{
    alert("Please input a valid email address!")
    testresults=false
    }
    return (testresults)
    }
    </script>

    <script language="JavaScript1.2">
    function checkbae(){
    if (document.layers||document.all)
    return checkemail()
    else
    return true
    }
    </script>

    <?
    //This grabs the form data and formats it and sends it in an email to you

    exit;
    ELSEIF (
    $action="Send"): 
    mail("$adminaddress","Comments""FAO: Admin @ $sitename \n
    First Name: 
    $fname 
    Last Name: 
    $lname
    Email Address: 
    $vemail
    Telephone Number: 
    $telno\n
    Questions/Comments:
    ------------------------------
    $comments
    ------------------------------

    Logged Info :
    ------------------------------
    Mailer: 
    $vers
    Using: 
    $HTTP_USER_AGENT
    Hostname: 
    $ip
    IP address: 
    $REMOTE_ADDR
    Date/Time:  
    $date","FROM:$adminaddress"); 

    //This grabs the form data and sends a confirmation to your visitor

    mail("$vemail","Thank you for visiting $sitename""Hi $fname,\n
    Thank you for your interest in 
    $sitename!
    We will read your comments as soon as we can and act accordingly.
    You can expect a response within 48hrs.\n
    Best regards,
    $sitename
    $siteaddress","from:$adminaddress"); 

    PRINT 
    "<br><br>";
    PRINT 
    "<br><br>";
    PRINT 
    "<html><head><title> $ptitle </title><body bgcolor=\"$bgcolor\" Link=\"$lcolor\" vLink=\"$lcolor\"><center>";
    PRINT 
    "<link rel=\"stylesheet\" href=\"form.css\" type=\"text/css\">";
    PRINT 
    "<table border=\"0\" cellspacing=\"5\" cellpadding=\"5\" width=\"75%\" bgcolor=\"$bocolor\">";
    PRINT 
    "<tr><td valign=\"top\" align=\"left\">";
    PRINT 
    "<table border=\"0\" cellspacing=\"5\" cellpadding=\"5\" width=\"100%\" bgcolor=\"$bgcolor\">";
    PRINT 
    "<tr><td valign=\"top\" align=\"left\"><font face=\"$font\" font size=\"$fontsize\" color=\"$fcolor\">Hello, <b>$fname</b>.";
    PRINT 
    "<br><br>";
    PRINT 
    "<font face=\"$font\" color=\"$fcolor\">Thank you for completing this form. <br>We'll send the information to your attention at  <b>$vemail</b>, within 48hrs.<br><br>";

    PRINT 
    "<font face=\"$font\" color=\"$f2color\">&nbsp;&nbsp;&nbsp+------------------------------------------------+<br>";
    PRINT 
    "<font face=\"$font\" color=\"$fcolor\">&nbsp;&nbsp;&nbsp;You submitted the following...<br>";
    PRINT 
    "<font face=\"$font\" color=\"$f2color\">&nbsp;&nbsp;&nbsp+------------------------------------------------+<br>";
    PRINT 
    "<font face=\"$font\" color=\"$fcolor\">&nbsp;&nbsp;&nbsp;First Name: <b>$fname</b><br>";
    PRINT 
    "<font face=\"$font\" color=\"$fcolor\">&nbsp;&nbsp;&nbsp;Last Name: <b>$lname</b><br>";
    PRINT 
    "<font face=\"$font\" color=\"$fcolor\">&nbsp;&nbsp;&nbsp;Email Address: <b>$vemail</b><br>";
    PRINT 
    "<font face=\"$font\" color=\"$fcolor\">&nbsp;&nbsp;&nbsp;Telephone Number: <b>$telno</b><br>";
    PRINT 
    "<font face=\"$font\" color=\"$fcolor\">&nbsp;&nbsp;&nbsp;Questions/Comments: <br>";
    PRINT 
    "<font face=\"$font\" color=\"$fcolor\">&nbsp;&nbsp;&nbsp;<b>$comments</b><br>";
    PRINT 
    "<font face=\"$font\" color=\"$f2color\">&nbsp;&nbsp;&nbsp+------------------------------------------------+<br>";
    PRINT 
    "<br><br>";

    PRINT 
    "<font face=\"$font\" color=\"$fcolor\">To close this window, 
    <a href=\"javascript:top.window.close()\">please click here</a>."
    ;

    PRINT 
    "</center></td></tr></table></td></tr></table>";
    ENDIF;
    ?>

    </body>
    </html>
    Thankx in advance,
    Arthur

  2. #2
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will have to recode this to work under "globals = off", or turn "globals" back on.

    PHP v4.3 globals are off by default.
    John

  3. #3
    SitePoint Zealot arthaus's Avatar
    Join Date
    Jun 2002
    Location
    Pasadena, CA
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi PHP John,

    Thankx for your input!

    I resolved it by defining the following...
    PHP Code:
    $name $_REQUEST['name'];
    $telephone $_REQUEST['telephone'];
    $email $_REQUEST['email'];
    $comments $_REQUEST['comments']; 
    ...and it works like a charm.

    Regards,
    Arthur

  4. #4
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent!
    John


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
  •