Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5

Thread: PHP script help

  1. #1
    Senior Member
    Join Date
    Aug 2003
    Posts
    194
    Member #
    2782
    Hello,
    Does anyone know how to alter this php script so that it would send an email saying "request received - check database" rather than sending all of the form data to the email? I am new to php, and fear that one slight mistake on my part might mess the entire script up!

    **********************************
    <?php
    include("global.inc.php");
    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    pt_register('POST','pickuplocation');
    pt_register('POST','pickuptimedate');
    pt_register('POST','returnlocation');
    pt_register('POST','returndatetime');
    pt_register('POST','vehicle');
    pt_register('POST','firstname');
    pt_register('POST','lastname');
    pt_register('POST','address');
    pt_register('POST','city');
    pt_register('POST','state');
    pt_register('POST','zip');
    pt_register('POST','country');
    pt_register('POST','phone');
    pt_register('POST','email');
    pt_register('POST','age');
    pt_register('POST','insurancecarrier');
    pt_register('POST','policy');
    pt_register('POST','coveragetill');
    pt_register('POST','agentname');
    pt_register('POST','agentphone');
    pt_register('POST','billfirstname');
    pt_register('POST','billlastname');
    pt_register('POST','billaddress');
    pt_register('POST','billcity');
    pt_register('POST','billstate');
    pt_register('POST','billzip');
    pt_register('POST','billcountry');
    pt_register('POST','billphone');
    pt_register('POST','creditcard');
    pt_register('POST','creditcardexp');
    pt_register('POST','dlnumber');
    pt_register('POST','dlstate');
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)){
    $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="pickuplocation: ".$pickuplocation."
    pickuptimedate: ".$pickuptimedate."
    returnlocation: ".$returnlocation."
    returndatetime: ".$returndatetime."
    vehicle: ".$vehicle."
    firstname: ".$firstname."
    lastname: ".$lastname."
    address: ".$address."
    city: ".$city."
    state: ".$state."
    zip: ".$zip."
    country: ".$country."
    phone: ".$phone."
    email: ".$email."
    age: ".$age."
    insurancecarrier: ".$insurancecarrier."
    policy: ".$policy."
    coveragetill: ".$coveragetill."
    agentname: ".$agentname."
    agentphone: ".$agentphone."
    billfirstname: ".$billfirstname."
    billlastname: ".$billlastname."
    billaddress: ".$billaddress."
    billcity: ".$billcity."
    billstate: ".$billstate."
    billzip: ".$billzip."
    billcountry: ".$billcountry."
    billphone: ".$billphone."
    creditcard: ".$creditcard."
    creditcardexp: ".$creditcardexp."
    dlnumber: ".$dlnumber."
    dlstate: ".$dlstate."
    ";
    $message = stripslashes($message);
    mail("myemail@mycompany.com","Request Received",$message,"From: $email");
    $link = mysql_connect("server","login","password");
    mysql_select_db("databasename",$link);
    $query="insert into tablename (pickuplocation,pickuptimedate,returnlocation,retu rndatetime,vehicle,firstname,lastname,address,city ,state,zip,country,phone,email,age,insurancecarrie r,policy,coveragetill,agentname,agentphone,billfir stname,billlastname,billaddress,billcity,billstate ,billzip,billcountry,billphone,creditcard,creditca rdexp,dlnumber,dlstate) values ('".$pickuplocation."','".$pickuptimedate."','". $r eturnlocation."','".$returndatetime."','".$vehicle ."','".$firstname."','".$lastname."','".$addres s." ','".$city."','".$state."','".$zip."','".$country . "','".$phone."','".$email."','".$age."','".$in sura ncecarrier."','".$policy."','".$coveragetill."','" .$agentname."','".$agentphone."','".$billfirstname ."','".$billlastname."','".$billaddress."','".$ bil lcity."','".$billstate."','".$billzip."','".$billc ountry."','".$billphone."','".$creditcard."','".$c reditcardexp."','".$dlnumber."','".$dlstate."')";
    mysql_query($query);

    header("Refresh: 0;url=http://www.mycompany.com/thankyou.htm");
    ?><?php
    }
    ?>

    ***********************

    Any assistance is greatly appreciated.

    Thank you!

  2.  

  3. #2
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Change this:

    PHP Code:
    message="pickuplocation: ".$pickuplocation."
    pickuptimedate: "
    .$pickuptimedate."
    returnlocation: "
    .$returnlocation."
    returndatetime: "
    .$returndatetime."
    vehicle: "
    .$vehicle."
    firstname: "
    .$firstname."
    lastname: "
    .$lastname."
    address: "
    .$address."
    city: "
    .$city."
    state: "
    .$state."
    zip: "
    .$zip."
    country: "
    .$country."
    phone: "
    .$phone."
    email: "
    .$email."
    age: "
    .$age."
    insurancecarrier: "
    .$insurancecarrier."
    policy: "
    .$policy."
    coveragetill: "
    .$coveragetill."
    agentname: "
    .$agentname."
    agentphone: "
    .$agentphone."
    billfirstname: "
    .$billfirstname."
    billlastname: "
    .$billlastname."
    billaddress: "
    .$billaddress."
    billcity: "
    .$billcity."
    billstate: "
    .$billstate."
    billzip: "
    .$billzip."
    billcountry: "
    .$billcountry."
    billphone: "
    .$billphone."
    creditcard: "
    .$creditcard."
    creditcardexp: "
    .$creditcardexp."
    dlnumber: "
    .$dlnumber."
    dlstate: "
    .$dlstate."
    "

    to this:

    PHP Code:
    message="request received - check database"
    choosy developers choose gif!
    website | paintings | blog

  4. #3
    Senior Member
    Join Date
    Aug 2003
    Posts
    194
    Member #
    2782
    When I changed the requested info, nothing went through (nothing was submitted to the database and no email was received). Also, the thankyou page did not show afterwards, instead the process.php URL showed in browser address field...

    what happened?

  5. #4
    Senior Member
    Join Date
    Aug 2003
    Posts
    194
    Member #
    2782
    Ahhhh. I figured it out. I had to remove the "$message" from the mail line and replace it with the text I wanted in the email. Thanks!

  6. #5
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    No that actually wasn't what I was suggesting... I was saying to change the stuff that's in the variable $message.

    I accidentally left out the $ before the variable name though, so if you left that out when you did it, that could be the problem.

    What you SHOULD do is comment out your header line (all the way at the bottom of your code) so it doesn't redirect after all that, so that it will display errors, and see what your errors are.

    It's better to do it the way you were doing it, setting the $message variable, then passing that to the function, so you have all your declarations separate from your function calls.
    choosy developers choose gif!
    website | paintings | blog


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:39 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com