Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question What's wrong with this??

    Could someone please tell me what is wrong with this code?? I new to PHP so please be gentle...
    Renroc

    <?php
    include("global.inc.php");
    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    pt_register('POST','firstname');
    pt_register('POST','lastname');
    pt_register('POST','emailaddress');
    if($firstname=="" || $lastname=="" || $emailaddress=="" ){
    $errors=1;
    $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
    }
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$emailaddress)){
    $error.="<li>Invalid email address entered";
    $errors=1;
    }
    if($errors==1) echo $error;
    else{
    $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
    $message="firstname: ".$firstname."
    lastname: ".$lastname."
    emailaddress: ".$emailaddress."
    ";
    $message = stripslashes($message);
    mail("me@somewhere.com","Form Submitted at Some Web Page website",$message,"From: Us");
    $make=fopen("admin/data.dat","a");
    $to_put="";
    $to_put .= $firstname."|".$lastname."|".$emailaddress."
    ";
    fwrite($make,$to_put);

    header("Refresh: 0;url=http://some url/page.htm");
    ?><?php
    }
    ?>

  • #2
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    Try this:

    PHP Code:
    <?php
    include("global.inc.php");
    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    pt_register('POST','firstname');
    pt_register('POST','lastname');
    pt_register('POST','emailaddress');
    if(
    $firstname=="" || $lastname=="" || $emailaddress=="" )
    {
        
    $errors=1;
        
    $error.="<li>
                    You did not enter one or more of the required fields. Please go back and try again.
                </li>"
    ;
    }
    elseif(!
    eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$emailaddress))
    {
        
    $error.="<li>
                    Invalid email address entered
                </li>"
    ;
        
    $errors=1;
    }
    elseif(
    $errors==1)
    {
        echo 
    $error;
    }
    else
    {
        
    $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
        
    $message="firstname: ".$firstname."
        lastname: "
    .$lastname."
        emailaddress: "
    .$emailaddress."
        "
    ;
        
    $message stripslashes($message);
        
    mail("me@somewhere.com","Form Submitted at Some Web Page website",$message,"From: Us");
        
    $make=fopen("admin/data.dat","a");
        
    $to_put $firstname."|".$lastname."|".$emailaddress;
        
    fwrite($make,$to_put);
        
    header("Location: http://www.example.com/");
    }
    ?>
    If that doesn't work, what errors are you getting, and on what line?

  • #3
    New Coder
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I found the mistake

    Thanks for your help, I found the mistake... If I have any more problems I'll post again.
    Thanks again
    Renroc


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •