php - Two different Paypal Forms based on User's Status -



php - Two different Paypal Forms based on User's Status -

i created website has registration form fundraiser event. has simple fields such "first name, lastly name, email, etc" after click on "submit" on first page, taken page can pay via paypal.

i know how insert paypal feature says "buy now". however, case, want have 2 different paypal forms:

if user has registered particular conference, pay $10 (i have list of registered attendees in database table via phpmyadmin) if user has not registered general conference, pay $15

how code can validate if user in database table of registered attendees , gets $10 rate? (perhaps can validate email address used on form)

this have right php file (it's defaulted on $15 regular rate non-attendees)

<html> <div class="container"> <head><title>payment page</title></head> <body> <h1>step 2: payment</h1> <p class="content">please proceed onto payment via paypal.</p> <div></div> <ul> <li>the fee attendee $10</li> <li>the fee non-attendee $15</li> </ul> </body> <head> <link rel="stylesheet" type="text/css" href="container.css"> </head> </html> <div></div> <br></br> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="tracyjones@gmail.com"> <input type="hidden" name="item_name" value="fundraiser"> <input type="hidden" name="item_number" value="rate"> <input type="hidden" name="amount" value="15.00"> <input type="hidden" name="no_shipping" value="0"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="usd"> <input type="hidden" name="lc" value="au"> <input type="hidden" name="bn" value="pp-buynowbf"> <input type="image" src="https://www.paypal.com/en_au/i/btn/btn_buynow_lg.gif" border="0" name="submit" alt="paypal - safer, easier way pay online."> <img alt="" border="0" src="https://www.paypal.com/en_au/i/scr/pixel.gif" width="1" height="1"> </form>

edited seek this:

<?php // event name $event = "2013 via-1 5k run fundraiser"; // registration fees attendees , non-attendees $fee_attendee = 10; $fee_nonattendee = 15; $paypal_email = 'payment@example.com '; // registration closing date (will go until 11:59 pm central standard time of day) $close_month = 03; $close_day = 08; $close_year = 2013; // $time = time(); easier utilize build in function of mysql. function clean($in) { $out = trim(strip_tags($in)); $out = addslashes($out); homecoming $out; } function listform(){ $host = "host"; $user = "username"; $password = "password"; $database = "dbname"; // open connection databse $link = mysqli_connect($host, $user, $password, $database); if (!$link){ echo ("unable connect database!"); } else { //get organisations table organisations $query = "select * organisations order name asc"; $result = mysqli_query($link, $query); while($row = mysqli_fetch_array($result, mysqli_both)){ echo "<option value=".$row['id_organisations'].">".$row['name']."</option>\n"; } } mysqli_close($link); } //check if variables post if filter input if not initiating variables form if (isset($_post['firstname'])){ $firstname = filter_var($_post['firstname'], filter_sanitize_string); } else { $firstname = ""; } if (isset($_post['lastname'])){ $lastname = filter_var($_post['lastname'],filter_sanitize_string); } else { $lastname = ""; } if (isset($_post['org'])){ $org = $_post['org']; } else { $org = ""; } if (isset($_post['email'])){ $email = filter_var(filter_var($_post['email'],filter_sanitize_email),filter_validate_email); } else { $email = ""; } if (isset($_post['attendant'])){ $attendant = filter_var(filter_var($_post['attendant'],filter_sanitize_string)); } else { $attendant = ""; } if (isset($_post['waiver'])){ $waiver = filter_var(filter_var($_post['waiver'],filter_sanitize_string)); } else { $waiver = ""; } function submit_form(){ $host = "host"; $user = "username"; $password = "password"; $database = "dbname"; $firstname = filter_var($_post['firstname'], filter_sanitize_string); $lastname = filter_var($_post['lastname'], filter_sanitize_string); $org = $_post['org']; $email = filter_var(filter_var($_post['email'],filter_sanitize_email),filter_validate_email); $attendant = $_post['attendant']; // open connection database $link = mysqli_connect($host,$user, $password, $database); if (!$link){ echo ("unable connect database!"); } else { //insert values database $query = "insert basicinfo (firstname,lastname,email,attendant,org,time) values('".$firstname."', '".$lastname."', '".$email."', ".$attendant.", ".$org.", now())"; homecoming mysqli_query($link,$query); } //close connection database mysqli_close($link); } function payment (){ $host = "host"; $user = "username"; $password = "password"; $database = "dbname"; $firstname = filter_var($_post['firstname'], filter_sanitize_string); $lastname = filter_var($_post['lastname'], filter_sanitize_string); // open connection databse $link = mysqli_connect($host, $user, $password, $database); if (!$link){ echo ("unable connect database!"); } else { //is registered @ other conference table registration $query = "select * registration firstname ='".$firstname."' , lastname='".$lastname."'"; $result = mysqli_query($link, $query); $rows = mysqli_fetch_array($result, mysqli_both); if ( $rows > 0){ $amount = 10.00; $form_registrar= <<< heredoc <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <div class="container"> <head><title>payment page</title></head> <link rel="stylesheet" type="text/css" href="container.css"> <body> <h1>step 2: payment</h1> <p class="content">please proceed onto payment via paypal.</p> <div></div> <ul> <li>the fee attendee $10</li> <li>the fee non-attendee $15</li> </ul> <div>your fee $$amount</div> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="tracyjones@gmail.com"> <input type="hidden" name="item_name" value="fundraiser"> <input type="hidden" name="item_number" value="rate"> <input type="hidden" name="amount" value="$amount"> <input type="hidden" name="no_shipping" value="0"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="usd"> <input type="hidden" name="lc" value="au"> <input type="hidden" name="bn" value="pp-buynowbf"> <input type="image" src="https://www.paypal.com/en_au/i/btn/btn_buynow_lg.gif" border="0" name="submit" alt="paypal - safer, easier way pay online."> <img alt="" border="0" src="https://www.paypal.com/en_au/i/scr/pixel.gif" width="1" height="1"> </form> </body> </html> heredoc; homecoming $form_registrar; } else { $amount = 15.00; $form_registrar= <<< heredoc <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <div class="container"> <head><title>payment page</title></head> <link rel="stylesheet" type="text/css" href="container.css"> <body> <h1>step 2: payment</h1> <p class="content">please proceed onto payment via paypal.</p> <div></div> <ul> <li>the fee attendee $10</li> <li>the fee non-attendee $15</li> </ul> <div>your fee $$amount</div> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="tracyjones@gmail.com"> <input type="hidden" name="item_name" value="fundraiser"> <input type="hidden" name="item_number" value="rate"> <input type="hidden" name="amount" value="$amount"> <input type="hidden" name="no_shipping" value="0"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="usd"> <input type="hidden" name="lc" value="au"> <input type="hidden" name="bn" value="pp-buynowbf"> <input type="image" src="https://www.paypal.com/en_au/i/btn/btn_buynow_lg.gif" border="0" name="submit" alt="paypal - safer, easier way pay online."> <img alt="" border="0" src="https://www.paypal.com/en_au/i/scr/pixel.gif" width="1" height="1"> </form> </body> </html> heredoc; homecoming $form_registrar; } } mysqli_close($link); } //warning messages initiation $warning_firstname = "*required"; $warning_lastname = "*required"; $warning_org = "*required"; $warning_email = "*required"; $warning_attendant = "*required"; $warning_waiver = "*required"; $formfirstpart = <<<eodformfirspart <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <title>form 5k run </title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <link href="style.css" type="text/css" rel="stylesheet" media="screen"/> </head> <body style="background-color:gold"> <div>we're excited introduce 5k run via-1! during year's conference, individuals can register participate in fun across university of iowa's campus in order raise money year's cpp</div> <div class="row"> <form action="{$_server['php_self']}" method="post" name="registration"> <div class="column grid_5"> <label for='first'>first name:</label></br> <input type="text" name="firstname" id="first" maxlength="25" tabindex='1' value="$firstname" /><span class="warning">$warning_firstname</span></br></br> <label for='first'>last name:</label></br> <input type="text" name="lastname" id='lastname' maxlength="25" tabindex='1' value="$lastname" /><span class="warning">$warning_lastname</span></br></br> <label for='email'>e-mail:</label></br> <input type="text" name="email" id='email' maxlength="100" tabindex='3' value="$email" /><span class="warning">$warning_email</span></br></br> <label for="org">organization:</label><br /> <select id="org" name="org" tabindex="5"> eodformfirspart; $formlastpart = <<<eodlastpart </select> <span class="warning">$warning_org</span><br /><br /> <label for='attendant'>are attending via-1?</label><br /> <input type='radio' class='radio' name='attendant' id='attendant-yes' value='1' /> <label for='attendant-yes'>yes</label><br /> <input type='radio' class='radio' name='attendant' id='attendant-no' value='0' /> <label for='attendant-no'>no </label><br />$warning_attendant<br /> <input type='checkbox' class="radio" name="waiver" id="waiver" value="1" /> <label for='waiver'>i understand , agree terms of <a href='waiver.php' target="_blank">the waiver</a>.$warning_waiver</label> </div> <div class='column grid_10 right'> <input type="submit" class='button' name="submit" value="submit" tabindex='7' /> </form> </div> </body> </html> eodlastpart; if(!isset($_post['submit'])){ // check if form not send, if not display empty form. echo $formfirstpart; echo listform(); echo $formlastpart; } elseif (isset($_post['submit']) , (isset($firstname) or isset($lastname) or isset($email) or isset($org) or isset($attendant))) { $warning_counter = 0; if ($firstname == "") { $warning_firstname = 'please provide first name , / or valid name'; $warning_counter = + 1 ; } if ($firstname == "") { $warning_lastname = 'please provide lastly name , / or valid name'; $warning_counter = + 1; } if ($email == "") { $warning_email = 'please provide email adress , / or valid email adress'; $warning_counter = +1; } if ($org == " ") { $warning_org = 'please select organisation'; $warning_counter = +1; } if ($waiver == "") { $warning_waiver = 'you have take waiver understanding otherwise cannot attend'; $warning_counter = +1; } if ($attendant == "") { $warning_attendant = 'do attend via-1?'; $warning_counter =+1; } if ($warning_counter>0){ $formfirstpart1 = <<<eodformfirspart1 <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <title>form 5k run </title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <link href="style.css" type="text/css" rel="stylesheet" media="screen"/> </head> <body style="background-color:gold"> <div>we're excited introduce 5k run via-1! during year's conference, individuals can register participate in fun across university of iowa's campus in order raise money year's cpp</div> <div class="row"> <form action="{$_server['php_self']}" method="post" name="registration"> <div class="column grid_5"> <label for='first'>first name:</label></br> <input type="text" name="firstname" id="first" maxlength="25" tabindex='1' value="$firstname" /><span class="warning">$warning_firstname</span></br></br> <label for='first'>last name:</label></br> <input type="text" name="lastname" id='lastname' maxlength="25" tabindex='1' value="$lastname" /><span class="warning">$warning_lastname</span></br></br> <label for='email'>e-mail:</label></br> <input type="text" name="email" id='email' maxlength="100" tabindex='3' value="$email" /><span class="warning">$warning_email</span></br></br> <label for="org">organization:</label><br /> <select id="org" name="org" tabindex="5"> eodformfirspart1; $formlastpart1 = <<<eodlastpart1 </select> <span class="warning">$warning_org</span><br /><br /> <label for='attendant'>are attending via-1?</label><br /> <input type='radio' class='radio' name='attendant' id='attendant-yes' value='1' /> <label for='attendant-yes'>yes</label><br /> <input type='radio' class='radio' name='attendant' id='attendant-no' value='0' /> <label for='attendant-no'>no </label><br />$warning_attendant<br /> <input type='checkbox' class="radio" name="waiver" id="waiver" value="1" /> <label for='waiver'>i understand , agree terms of <a href='waiver.php' target="_blank">the waiver</a>.$warning_waiver</label> </div> <div class='column grid_10 right'> <input type="submit" class='button' name="submit" value="submit" tabindex='7' /> </form> </div> </body> </html> eodlastpart1; echo $formfirstpart1; echo listform(); echo $formlastpart1; } if ($warning_counter == 0){ submit_form(); echo payment(); } } ?>

php sql forms paypal registration

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -