Jump to content

This is Killing me


williamsk

Recommended Posts

I've tried lots of stuff. I'm not a php guru (obviously) But i can't figure out what to put in the action field (it's full of question marks right now.) Can some one tackle this and help me out?

 

<?php

 

function is_valid_email_address($email){

  return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);

}

 

function getValue($pValue) {

  $returnValue = !empty($_POST[$pValue]) ? stripslashes(trim($_POST[$pValue])) : NULL;

  if( empty($returnValue)) {

      switch($pValue) {

        case "firstname":

            $returnValue = "First Name";

            break;

        case "lastname":

            $returnValue = "Last Name";

            break;

        case "phone_no":

            $returnValue = "Phone Number";

            break;

        case "email_add":

            $returnValue = "Email Address";

            break;

 

      }

  }

  return $returnValue;

}

 

$errors = array();

$formProcessed = FALSE;

$fs = getValue("fs");

if(!empty($fs) && $fs == "y") {

  $confirm = getValue("confirm");

  if( empty($confirm) || $confirm <> "yes" ) { $errors["confirm_required"] = "required"; }

 

  $firstname = getValue("firstname");

  if( empty($firstname) || $firstname == "First Name" ) { $errors["firstname_required"] = "required"; }

  if( !ctype_alpha(str_replace(" ","",$firstname)) ) {$errors["firstname_not_string"] = "string"; }

 

  $lastname = getValue("lastname");

  if( empty($lastname) || $lastname == "Last Name" ) { $errors["lastname_required"] = "required"; }

  if( !ctype_alpha(str_replace(" ","",$lastname)) ) {$errors["lastname_not_string"] = "string"; }

 

  $phone_no = getValue("phone_no");

  if( empty($phone_no) || $phone_no == "Phone Number" ) { $errors["phone_no_required"] = "required"; }

 

  $email_add = getValue("email_add");

    if( empty($email_add) || $email_add == "Email Address" ) {

      $errors["email_add_required"] = "required";

    } else {

      if( !is_valid_email_address($email_add) ) {

        $errors["email_add_invalid"] = "invalid";

      }

    }

 

 

    if( empty($errors)) {

      $formProcessed = TRUE;

    }

}

 

if( $formProcessed ) {

  $to = "[email protected]";

  $headers = "From: [email protected]";

  $subject = "Merchant Prospect Form Capture";

  $message = "First Name: ".getValue("firstname")."\r\n";

  $message = "Last Name: ".getValue("lastname")."\r\n";

  $message.= "Phone Number: ".getValue("phone_no")."\r\n";

  $message.= "Email Address: ".getValue("email_add")."\r\n";

 

  mail($to,$subject,$message,$headers);

?>

<div id="getContainer">

  <img src="images/bttn_getstarted.gif" alt="Get Started" width="166" height="13" border="0" />

    <p style="font-size:9px">Thank you!  Someone from Rewards Network will be contacting you shortly.</p>

</div>

<?php

} else {

?>

              <div id="getContainer">

<a href="#" onmouseover="showLayer('lyr5'); return false"><img src="images/bttn_getstarted.gif" alt="Get Started" width="166" height="13" border="0" /></a>

<?php if( empty($errors)) { ?>

  <div id="lyr5">

<?php } else { ?>

  <div id="lyr5" style="visibility: visible;">

<?php } ?>

<a href="#" onclick="hideLayer('lyr5'); return false"><img src="images/bttn_close.gif" alt="CLOSE" width="11" height="9" border="0" align="right" /></a>

                  <p>

                     

                  </p>

                  <p>

                    Want to get started right away? A representative will

                    contact you.

                  </p><br />

                  <form name="get_started" id="get_started" action="????????" method="post">

                  <input type="hidden" name="fs" value="y" />

 

  <input type=hidden name="oid" value="00D500000007WCl" />

  <input type=hidden name="retURL" value="http://localhost/rcr/thank_you.htm" />

                  <input type=hidden name="lead_source" value="Web" />

 

 

                  <p align="right"><small>[All fields required.]</small></p>

<?php if(!empty($errors["firstname_required"])) { ?><p class="error-red">First Name is required</p><?php } ?>

<?php if(!empty($errors["firstname_not_string"])) { ?><p class="error-red">First Name can only contain letters</p><?php } ?>

                  <input name="first_name" id="firstname" maxlength="100" size="23" value="<?php echo getValue("firstname");?>" onfocus="value=''" /><br />

<?php if(!empty($errors["lastname_required"])) { ?><p class="error-red">Last Name is required</p><?php } ?>

<?php if(!empty($errors["lastname_not_string"])) { ?><p class="error-red">Last Name can only contain letters</p><?php } ?>

                  <input name="last_name" id="lastname" maxlength="100" size="23" value="<?php echo getValue("lastname");?>" onfocus="value=''" /><br />

<?php if(!empty($errors["phone_no_required"])) { ?><p class="error-red">Phone Number is required</p><?php } ?>

                  <input name="phone" id="phone_no" maxlength="100" size="23" value="<?php echo getValue("phone_no");?>" onfocus="value=''" /><br />

<?php if(!empty($errors["email_add_required"])) { ?><p class="error-red">Email Address is required</p><?php } ?>

<?php if(!empty($errors["email_add_invalid"])) { ?><p class="error-red">Email Address is not properly formed</p><?php } ?>

                  <input name="email" id="email_add" maxlength="100" size="23" value="<?php echo getValue("email_add");?>" onfocus="value=''" /><br />

 

                    <table cellpadding="5">

                      <tr>

                        <td colspan="2">

                          <br />

                          <p style="font-size:9px">

                            Contact us ASAP at 800-422-5155

                          </p> 

                        </td>

                      </tr>

<?php if(!empty($errors["confirm_required"])) { ?>

<tr><td valign="top" colspan="2"><span class="error-red">You must check the box below</span></td></tr>

<?php } ?>

                      <tr>

                        <td valign="top">

                          <input type="checkbox" name="confirm" id="confirm" value="yes" />

                        </td>

                        <td valign="top">

                          <p style="font-size:9px">

                            I agree to the terms and conditions as listed in

                            the <a href="terms_conditions.php" onclick=

                            "OpenSmall(this.href); return false">Web site Terms

                            of Use</a> and consent to the collection and use of

                            my personal information in accordance with our

                            <a href="privacy_policy.php" onclick=

                            "OpenSmall(this.href); return false">Privacy

                            Policy</a>.

                          </p>

                        </td>

                      </tr>

                    </table><br />

                    <input name="submit" type="image" src="images/bttn_submit.gif" alt="Submit" align="right" />

                  </form>

                </div>

              </div>

<?php

}

?>

Link to comment
https://forums.phpfreaks.com/topic/86489-this-is-killing-me/
Share on other sites

Sorry

 

 

I've tried lots of stuff. I'm not a php guru (obviously) But i can't figure out what to put in the action field (it's full of question marks right now.) Can some one tackle this and help me out?

 

<?php

function is_valid_email_address($email){
  return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}

function getValue($pValue) {
   $returnValue = !empty($_POST[$pValue]) ? stripslashes(trim($_POST[$pValue])) : NULL;
   if( empty($returnValue)) {
      switch($pValue) {
         case "firstname":
            $returnValue = "First Name";
            break;
         case "lastname":
            $returnValue = "Last Name";
            break;
         case "phone_no":
            $returnValue = "Phone Number";
            break;
         case "email_add":
            $returnValue = "Email Address";
            break;

      }
   }
   return $returnValue;
}

$errors = array();
$formProcessed = FALSE;
$fs = getValue("fs");
if(!empty($fs) && $fs == "y") {
   $confirm = getValue("confirm");
   if( empty($confirm) || $confirm <> "yes" ) { $errors["confirm_required"] = "required"; }

   $firstname = getValue("firstname");
   if( empty($firstname) || $firstname == "First Name" ) { $errors["firstname_required"] = "required"; }
   if( !ctype_alpha(str_replace(" ","",$firstname)) ) {$errors["firstname_not_string"] = "string"; }

   $lastname = getValue("lastname");
   if( empty($lastname) || $lastname == "Last Name" ) { $errors["lastname_required"] = "required"; }
   if( !ctype_alpha(str_replace(" ","",$lastname)) ) {$errors["lastname_not_string"] = "string"; }

   $phone_no = getValue("phone_no");
   if( empty($phone_no) || $phone_no == "Phone Number" ) { $errors["phone_no_required"] = "required"; }

   $email_add = getValue("email_add");
    if( empty($email_add) || $email_add == "Email Address" ) {
      $errors["email_add_required"] = "required";
    } else {
      if( !is_valid_email_address($email_add) ) {
        $errors["email_add_invalid"] = "invalid";
      }
    }


    if( empty($errors)) {
      $formProcessed = TRUE;
    }
}

if( $formProcessed ) {
   $to = "[email protected]";
   $headers = "From: [email protected]";
   $subject = "Merchant Prospect Form Capture";
   $message = "First Name: ".getValue("firstname")."\r\n";
   $message = "Last Name: ".getValue("lastname")."\r\n";
   $message.= "Phone Number: ".getValue("phone_no")."\r\n";
   $message.= "Email Address: ".getValue("email_add")."\r\n";

   mail($to,$subject,$message,$headers);
?>
<div id="getContainer">
   <img src="images/bttn_getstarted.gif" alt="Get Started" width="166" height="13" border="0" />
    <p style="font-size:9px">Thank you!  Someone from Rewards Network will be contacting you shortly.</p>
</div>
<?php
} else {
?>
              <div id="getContainer">
<a href="#" onmouseover="showLayer('lyr5'); return false"><img src="images/bttn_getstarted.gif" alt="Get Started" width="166" height="13" border="0" /></a>
<?php if( empty($errors)) { ?>
   <div id="lyr5">
<?php } else { ?>
   <div id="lyr5" style="visibility: visible;">
<?php } ?>
<a href="#" onclick="hideLayer('lyr5'); return false"><img src="images/bttn_close.gif" alt="CLOSE" width="11" height="9" border="0" align="right" /></a>
                  <p>
                     
                  </p>
                  <p>
                    Want to get started right away? A representative will
                    contact you.
                  </p><br />
                  <form name="get_started" id="get_started" action="????????" method="post">
                  <input type="hidden" name="fs" value="y" />

	  <input type=hidden name="oid" value="00D500000007WCl" />
	  <input type=hidden name="retURL" value="http://localhost/rcr/thank_you.htm" />
                  <input type=hidden name="lead_source" value="Web" />


                  <p align="right"><small>[All fields required.]</small></p>
<?php if(!empty($errors["firstname_required"])) { ?><p class="error-red">First Name is required</p><?php } ?>
<?php if(!empty($errors["firstname_not_string"])) { ?><p class="error-red">First Name can only contain letters</p><?php } ?>
                  <input name="first_name" id="firstname" maxlength="100" size="23" value="<?php echo getValue("firstname");?>" onfocus="value=''" /><br />
<?php if(!empty($errors["lastname_required"])) { ?><p class="error-red">Last Name is required</p><?php } ?>
<?php if(!empty($errors["lastname_not_string"])) { ?><p class="error-red">Last Name can only contain letters</p><?php } ?>
                  <input name="last_name" id="lastname" maxlength="100" size="23" value="<?php echo getValue("lastname");?>" onfocus="value=''" /><br />
<?php if(!empty($errors["phone_no_required"])) { ?><p class="error-red">Phone Number is required</p><?php } ?>
                  <input name="phone" id="phone_no" maxlength="100" size="23" value="<?php echo getValue("phone_no");?>" onfocus="value=''" /><br />
<?php if(!empty($errors["email_add_required"])) { ?><p class="error-red">Email Address is required</p><?php } ?>
<?php if(!empty($errors["email_add_invalid"])) { ?><p class="error-red">Email Address is not properly formed</p><?php } ?>
                  <input name="email" id="email_add" maxlength="100" size="23" value="<?php echo getValue("email_add");?>" onfocus="value=''" /><br />

                    <table cellpadding="5">
                      <tr>
                        <td colspan="2">
                          <br />
                          <p style="font-size:9px">
                            Contact us ASAP at 800-422-5155
                          </p> 
                        </td>
                      </tr>
<?php if(!empty($errors["confirm_required"])) { ?>
<tr><td valign="top" colspan="2"><span class="error-red">You must check the box below</span></td></tr>
<?php } ?>
                      <tr>
                        <td valign="top">
                          <input type="checkbox" name="confirm" id="confirm" value="yes" />
                        </td>
                        <td valign="top">
                          <p style="font-size:9px">
                            I agree to the terms and conditions as listed in
                            the <a href="terms_conditions.php" onclick=
                            "OpenSmall(this.href); return false">Web site Terms
                            of Use</a> and consent to the collection and use of
                            my personal information in accordance with our
                            <a href="privacy_policy.php" onclick=
                            "OpenSmall(this.href); return false">Privacy
                            Policy</a>.
                          </p>
                        </td>
                      </tr>
                    </table><br />
                    <input name="submit" type="image" src="images/bttn_submit.gif" alt="Submit" align="right" />
                  </form>
                </div>
              </div>
<?php
}
?>

Link to comment
https://forums.phpfreaks.com/topic/86489-this-is-killing-me/#findComment-441958
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.