Jump to content

Form Validation and then to PAYPAL help


pstanbra

Recommended Posts

Hi - I've found a great little script to use as form validation. However - on my form - the action needs to be changed to PHP_SELF. Seems the form data is pushed into an array and then error checking is done on this.

In the added code, there is a section here;

  // no errors! redirect the user to the thankyou page (or whatever)
  else 
  {
   	

  }
}

 

So my question is - how do I send my form variables (now error checked) to www.Paypal.com/webscr

 

 

 

 

My Form Page;

 

<?php

$errors = array(); // set the errors array to empty, by default
$fields = array(); // stores the field values
$success_message = "";

if (isset($_POST['submit']))
{
  // import the validation library
  require("validation.php");

  $rules = array(); // stores the validation rules


  $rules[] = "range<100,number_range_less_than,Please enter a number less than 100.";

  $errors = validateFields($_POST, $rules);

  // if there were errors, re-populate the form fields
  if (!empty($errors))
  {  
    $fields = $_POST;
  }
  
  // no errors! redirect the user to the thankyou page (or whatever)
  else 
  {
   
*******need to send my form info to paypal ************

  }
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>PHP Validation Demo</title>

  <style type="text/css">
  <!--
  
  body,p,table,td,input,select {
    font-family: arial;
  	font-size: 8pt;
  }
  .demoTable {
    background-color: #efefef;
    width: 400px;
  }
  .error {
    border: 1px solid red;
    background-color: #ffffee;
    color: #660000;
    width: 400px;
    padding: 5px;
  }
  .notify {
    border: 1px solid #336699;
    background-color: #ffffee;
    color: #336699;
    width: 400px;
    padding: 5px;
  }
  
  -->
  </style>

</head>
<body>

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">

<p><b><u>PHP Validation Demo</u></b></p>

<p>
  This form contains all the validation options that are offered by the 
  validation.php function library. To see how the code works, <a href="file:///C|/Documents and Settings/stanbrap/Desktop/php_validation/php_validation.zip">download the
source code here</a>.
</p>

<?php

// if $errors is not empty, the form must have failed one or more validation 
// tests. Loop through each and display them on the page for the user
if (!empty($errors))
{
  echo "<div class='error'>Please fix the following errors:\n<ul>";
  foreach ($errors as $error)
    echo "<li>$error</li>\n";

  echo "</ul></div>"; 
}

if (!empty($success_message))
{
  echo "<div class='notify'>$success_message</div>";
  
}
?>

<p> </p>

<table class="demoTable">
<tr>
  <td>nter a number less than 100:</td>
<td><input type="text" name="number_range_less_than" value="<?=$fields['number_range_less_than']?>" /></td>
</tr>
</table>

<p><i>Length of field input</i></p>
<input type="hidden" name="cmd" value="_xclick">
  <input type="hidden" name="business" value="<?PHP echo $business;?>">
  <input type="hidden" name="item_name" value="Donation">
  <input type="hidden" name="item_number" value="donation">
  <input type="hidden" name="currency_code" value="<?PHP echo $currency_code;?>">
  <input type="hidden" name="notify_url" value="<?PHP echo $notify_url;?>">

  <input type="hidden" name="return" value="<?PHP echo $return;?>">
  <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<p><input type="submit" name="submit" value="SUBMIT" /></p>

</form>

</body>
</html>

 

 

 

 

Link to comment
Share on other sites

Is this really neccessary? I only want to do the same as click on submit on a form and send/POST to the paypal link.

The only difference is that my form fields are sent to PHP_self for checking - once checks are correct - the function should be the same post for to paypal

Link to comment
Share on other sites

"Is this really neccessary? I only want to do the same as click on submit on a form and send/POST to the paypal link.

The only difference is that my form fields are sent to PHP_self for checking - once checks are correct - the function should be the same post for to paypal"

 

So at the end of the checking, use the header('Location'); command.

 

"You should use javascript for form validation, no server load that way."

You can't use ONLY client-side validation, you must have some server-side.

 

Link to comment
Share on other sites

So at the end of the checking, use the header('Location'); command.

Yes I did think that but simply adding that takes you to paypals page - as apposed to having fields sent to the paypal script by the form post command.

 

how do i use header yet send all the fields from the form now stored in the array

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.