Web Hosting Talk







View Full Version : Undefined Index


stuffradio
03-24-2007, 08:52 PM
This error is annoying me....


also some reason some of my variables aren't being passed through a form some reason :S


Notice: Undefined index: email on line 12

Notice: Undefined variable: email on line 183

Notice: Undefined index: fName on line 206

Notice: Undefined index: lName on line 206

Notice: Undefined index: email on line 206


Line 12:

$email = $_POST['email'];


Line 183:

$_SESSION['email'] = $email;


Line 206 an insert query with:

'$_POST[fName]', '$_POST[lName]'

as some values.

Help :)

horizon
03-24-2007, 10:07 PM
also some reason some of my variables aren't being passed through a form some reason


Would it be possible to see the entire HTML Form and the PHP file you're using ?

spt1224
03-24-2007, 10:10 PM
You can get rid of such notices by checking that the indices are set before using them. For example:


if (isset($_POST["email"])) {
$email = $_POST["email"];
} else {
$email = "";
}


However, even if the form fields are left blank they should show up in $_POST as empty strings. Without seeing the form, the only thing I can think of that would cause the notices to appear would be that the corresponding elements of the form have their "id" attribute set but not their "name" attribute, which is used to index the $_POST array.

horizon
03-24-2007, 10:18 PM
Since this is about email verification, I would recommend checking the email format to assure it's validation before inserting the results into the database.


if (isset($_POST['email']) && preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', $_POST['email'])) {
$email = (stripslashes(trim($_POST['email'])));
} else {
$email = "";
echo "Invalid email format. Please try again.";
}

;)

stuffradio
03-24-2007, 11:00 PM
Here is the form:

<table width='650' border='0' cellspacing='0' cellpadding='0'>
<form action='verify.php' method='post'>
<tr>
<td><img src='im/join_form/contact_info.gif' alt='Contact Information' width='650' height='25' /></td>
</tr>
<tr>
<td align='left' valign='top' background='im/join_form/borders_bg.gif' class='jft_bottom_border jft_form_padding'><table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'><strong>First Name(s): </strong></td>
<td width='182' height='30'><input type='text' name='fName' value='$_SESSION[fName]' /></td>
<td width='134' height='30'><strong>Last Name(s): </strong></td>
<td width='179' height='30'><input type='text' name='lName' value='$_SESSION[lName]' /></td>
</tr>
<tr>
<td width='135' height='30'><strong>Primary Phone:</strong> </td>
<td height='30'><input type='text' name='pPhone' value='$_SESSION[pPhone]' /></td>
<td height='30'>Secondary Phone: </td>
<td height='30'><input type='text' name='sPhone' value='$_SESSION[sPhone]' /></td>
</tr>
<tr>
<td height='20' colspan='4'><hr color='#CCCCCC' size='1px' /></td>
</tr>
</table>
<table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'>E-mail Address: </td>
<td width='285' height='30'><input name='email' value='$_SESSION[email]' type='text' size='40' /></td>
<td width='210' rowspan='2' align='left' valign='middle'><span class='style1'>By entering your e-mail address you agree to recieve relevant e-mails from Mount Royal Community Association and its affiliates. </span></td>
</tr>
<tr>
<td width='135' height='30'>Confirm E-mail: </td>
<td height='30'><input name='confirm_email' type='text' size='40' /></td>
</tr>
<tr>
<td height='20' colspan='3'><hr color='#CCCCCC' size='1px' /></td>
</tr>
</table>
<table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'><strong>Create Password:</strong></td>
<td width='493' height='30'><input name='password' value='$_SESSION[password]' type='text' size='40' /></td>
</tr>
<tr>
<td width='135' height='30'><strong>Confirm Password: </strong></td>
<td height='30'><input name='cPassword' type='text' size='40' /></td>
</tr>
</table>
<hr color='#CCCCCC' size='1px' />
<table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'><strong>Secret Question :</strong> </td>
<td width='285' height='30'><input name='s_Question' value='$_SESSION[s_Question]' type='text' size='40' /></td>
<td width='210' rowspan='2' align='left' valign='middle'><span class='style1'>This will be used incase you need to recover the password for your membership account. </span></td>
</tr>
<tr>
<td width='135' height='30'><strong>Answer: </strong></td>
<td height='30'><input name='qAnswer' value='$_SESSION[qAnswer]' type='text' size='40' /></td>
</tr>
<tr>
<td height='20' colspan='3'><hr color='#CCCCCC' size='1px' /></td>
</tr>
</table></td>
</tr>
</table>
<br />
<table width='650' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><img src='im/join_form/address_info.gif' alt='Contact Information' width='650' height='25' /></td>
</tr>
<tr>
<td align='left' valign='top' background='im/join_form/borders_bg.gif' class='jft_bottom_border jft_form_padding'><table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'>Unit Number: </td>
<td width='100' height='30'><input name='uNumber' value='$_SESSION[uNumber]' type='text' size='10' /></td>
<td width='128' height='30'><strong>Building Number: </strong></td>
<td height='30'><input name='bNumber' value='$_SESSION[bNumber]' type='text' size='10' /></td>
</tr>
</table>
<table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'><strong>Road Name:</strong></td>
<td height='30'><input name='rName' value='$_SESSION[rName]' type='text' size='65' /></td>
</tr>
</table>
<table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'><strong>Road Type: </strong></td>
<td width='100' height='30'><select name='rType' value='$_SESSION[rType]'>
<option value='Avenue'>Avenue</option>
<option value='Circle'>Circle</option>
</select>
</td>
<td width='126' height='30'>City Quadrant: </td>
<td><select name='cQuadrant' value='$_SESSION[cQuadrant]'>
<option value='NW'>NW</option>
<option value='NE'>NE</option>
<option value='SW'>SW</option>
<option value='SE'>SE</option>
</select>
</td>
</tr>
</table>
<table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'><strong>City:</strong></td>
<td width='100' height='30'><select name='city' value='$_SESSION[city]'>
<option value='Calgary'>Calgary</option>
<option value='Other'>Other</option>
</select>
</td>
<td width='126' height='30'>If Other City: </td>
<td><input type='text' name='oCity' value='' /></td>
</tr>
</table>
<table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'><strong>Province:</strong></td>
<td width='100' height='30'><select name='province' value='@$_SESSION[province]'>
<option value='Alberta'>Alberta</option>
<option value='Other'>Other</option>
</select>
</td>
<td width='126' height='30'>If Other Province: </td>
<td><input type='text' name='oProvince' value='' /></td>
</tr>
</table>
<table width='235' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'><strong>Postal Code </strong></td>
<td width='100' height='30'><input name='pCode' type='text' size='10' /></td>
</tr>
</table></td>
</tr>
</table>
<br />
<table width='650' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><img src='im/join_form/child_info.gif' alt='Contact Information' width='650' height='25' /></td>
</tr>
<tr>
<td align='left' valign='top' background='im/join_form/borders_bg.gif' class='jft_bottom_border jft_form_padding'><table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='135' height='30'><strong>Children at Home:</strong><br /></td>
<td width='25' height='15' align='center' valign='middle'><input type='checkbox' name='childHome' value='Yes' /></td>
<td width='150'>No Children at Home </td>
<td width='25' align='center' valign='middle'><input type='checkbox' name='noChild' value='Yes' /></td>
<td width='135'>5 - 12 Years </td>
<td width='25' align='left' valign='middle'><input type='checkbox' name='fTwelve' value='Yes' /></td>
<td>16 - 18 Years </td>
</tr>
<tr>
<td height='30'><span class='style1'>(check all that apply)</span> </td>
<td width='25' height='30' align='center' valign='middle'><input type='checkbox' name='sEighteen' value='Yes' /></td>
<td width='150' height='30'>Under 5 Years </td>
<td width='25' height='30' align='center' valign='middle'><input type='checkbox' name='uFive' value='Yes' /></td>
<td width='135' height='30'>12 - 16 Years </td>
<td width='25' height='30' align='left' valign='middle'><input type='checkbox' name='tSixteen' value='Yes' /></td>
<td height='30'>Over 18 Years </td>
</tr>
</table>
</td>
</tr>
</table>
<br />
<table width='650' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><img src='im/join_form/payment_info.gif' alt='Contact Information' width='650' height='25' /></td>
</tr>
<tr>
<td align='left' valign='top' background='im/join_form/borders_bg.gif' class='jft_bottom_border jft_form_padding'><table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='134' height='30'><strong>Membership Type: </strong><br /></td>
<td width='25' height='30' align='center' valign='middle'><input name='member' type='radio' value='Family' /></td>
<td width='471'>Family - $45 / Year (Includes Tennis) </td>
</tr>
<tr>
<td width='134' height='30' rowspan='2'>&nbsp;</td>
<td width='25' height='30' align='center' valign='middle'><input name='member' type='radio' value='Senior' /></td>
<td width='471' height='35'>Senior - $20 / Year (Includes Tennis)<br />
One household member over 65 years</td>
</tr>
<tr>
<td width='25' height='30' align='center' valign='middle'><input name='member' type='radio' value='Associate' /></td>
<td height='30'>Associate - $20 / Year </td>
</tr>
</table>
<hr color='#CCCCCC' size='1px' />
<table width='630' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='134' height='30'><strong>Payment Method: </strong><br /></td>
<td width='25' height='30' align='center' valign='middle'><input name='payment' type='radio' value='Credit Card' /></td>
<td width='471'>Credit Card (Online) </td>
</tr>
<tr>
<td width='134' height='30' rowspan='3'>&nbsp;</td>
<td width='25' height='30' align='center' valign='middle'><input name='payment' type='radio' value='Cheque / Money Order(Mail)' /></td>
<td width='471' height='30'>Cheque / Money Order (Mail) </td>
</tr>
<tr>
<td width='25' height='30' align='center' valign='middle'><input name='payment' type='radio' value='Cheque / Money Order(Drop-Off)' /></td>
<td height='30'>Cheque / Money Order (Drop-Off) </td>
</tr>
<tr>
<td width='25' height='30' align='center' valign='middle'><input name='payment' type='radio' value='Cash (Drop-Off)' /></td>
<td height='30'>Cash (Drop-Off) </td>
</tr>
</table>
</td>
</tr>
</table>
<p>
<input type='submit' name='Apply' value='Submit Membership Application' />
<input type='reset' value='Clear Application Form' />
</p>
</form>";

horizon
03-25-2007, 08:57 AM
And ... the PHP file which validates these values ?

In the mean time, I'd change:


<input type='text' name='fName' value='$_SESSION[fName]' />

with:


<input type='text' name='fName' value='<?php echo $_SESSION['fName']; ?>'/>

and do the rest with all my inputs. ;)

stuffradio
03-25-2007, 05:35 PM
here is the php part:


<?php
require('config.php');
include('joinfunction.php');

$register = new Register();
@$apply = $_POST['Apply'];
@$fName = $_POST['fName'];
@$lName = $_POST['lName'];
@$pPhone = $_POST['pPhone'];
@$sPhone = $_POST['sPhone'];
$email = $_POST['email'];
@$password = @$_POST['password'];
@$cpass = $_POST['cPassword'];
@$s_Question = $_POST['s_Question'];
@$qAnswer = $_POST['qAnswer'];
@$uNumber = $_POST['uNumber'];
@$bNumber = $_POST['bNumber'];
@$rName = $_POST['rName'];
@$rType = $_POST['rType'];
@$cQuadrant = $_POST['cQuadrant'];
@$city = $_POST['city'];
@$oCity = $_POST['oCity'];
@$province = $_POST['province'];
@$oProvince = $_POST['oProvince'];
@$pCode = $_POST['pCode'];
@$childHome = $_POST['childHome'];
@$noChild = $_POST['noChild'];
@$fTwelve = $_POST['fTwelve'];
@$sEighteen = $_POST['sEighteen'];
@$uFive = $_POST['uFive'];
@$tSixteen = $_POST['tSixteen'];
@$member = $_POST['member'];
@$payment = $_POST['payment'];
@$date = date('d/m/Y');
$_SESSION['apply'] = $apply;
$_SESSION['fName'] = $fName;
$_SESSION['lName'] = $lName;
$_SESSION['pPhone'] = $pPhone;
$_SESSION['sPhone'] = $sPhone;
$_SESSION['email'] = $email;
$_SESSION['password'] = $password;
$_SESSION['s_Question'] = $s_Question;
$_SESSION['qAnswer'] = $qAnswer;
$_SESSION['uNumber'] = $uNumber;
$_SESSION['bNumber'] = $bNumber;
$_SESSION['rName'] = $rName;
$_SESSION['rType'] = $rType;
$_SESSION['cQuadrant'] = $cQuadrant;
$_SESSION['city'] = $city;
$_SESSION['oCity'] = $oCity;
$_SESSION['province'] = $province;
$_SESSION['oProvince'] = $oProvince;
$_SESSION['pCode'] = $pCode;
$_SESSION['childHome'] = $childHome;
$_SESSION['noChild'] = $noChild;
$_SESSION['fTwelve'] = $fTwelve;
$_SESSION['sEighteen'] = $sEighteen;
$_SESSION['uFive'] = $uFive;
$_SESSION['tSixteen'] = $tSixteen;
$_SESSION['member'] = $member;
$_SESSION['payment'] = $payment;


if ($fName == "" && $apply) {
echo "No First Name was entered.";
} elseif ($lName == "" && $apply) {
echo "No Last Name was entered.";
} elseif ($password == "" && $apply) {
echo "No Password was entered.";
} elseif ($cpass == "" && $apply) {
echo "No Confirmation Password was entered.";
} elseif ($cpass != $password && $apply) {
echo "Confirmation password and password do not match.";
} elseif ($s_Question == "" && $apply) {
echo "No Secret question was entered.";
} elseif ($qAnswer == "" && $apply) {
echo "No Answer was entered.";
} elseif ($bNumber == "" && $apply) {
echo "No building number was entered.";
} elseif ($rName == "" && $apply) {
echo "No Road Name was entered.";
} elseif ($pCode == "" && $apply) {
echo "No postal Code was entered.";
} elseif ($member == "" && $apply) {
echo "You have not specified a member type.";
} elseif ($payment == "" && $apply) {
echo "You have not specifed a Payment Type for your membership.";
} elseif($payment == "Cash (Drop-Off)" && $email == "" || $payment == "Cheque / Money Order(Drop-Off)" && $email == "" || $payment == "Cheque / Money Order (Mail)" && $email == "" && $apply) {
$register->approval("regular", "decline");


} elseif ($payment == "Cash (Drop-Off)" && $email != "" || $payment == "Cheque / Money Order(Drop-Off)" && $email != "" || $payment == "Cheque / Money Order (Mail)" && $email != "" && $apply) {
$register->approval("regularmail", "decline");


}
if (@$_POST['regular']) {
echo "Thank you for your interest in applying to be a member. Your application has been put into cue for approval. You will be notified via telephone or regular mail if/when your membership is approved, and arrangements for payment will be made.";
$register->addMember();
} elseif (@$_POST['regularmail']) {
$register->addMember();
echo "Thank you for your interest in applying to be a member. Your application has been put into cue for approval. You will be notified via email if/when your membership is approved, and arrangements for payment will be made.";
$message = "Thank you for your interest in applying to be a member. Your application has been put into cue for approval. You will be notified via email if/when your membership is approved, and arrangements for payment will be made.";
$from = "From: MRCA Administration";
mail($email, 'MRCA Membership Confirmation', '$message', '$from');
echo "Email sent successfully to $email!";
}
if (@$_POST['decline']) {
header("Location: join.php");
}


?>

There are two functions, one function displays a table with the information they posted, and the other one contains the query that inserts them in to the table. On the function that displays the table, the correct information shows up.... but doesn't insert in to the table properly :S

horizon
03-25-2007, 07:23 PM
Wow, that required some time. Meh - like PHP too dang much anyways. ;)

Here:


<?php
require('config.php');
include('joinfunction.php');

$register = new Register();
@$apply = (isset($_POST['Apply'])) ? (stripslashes(trim($_POST['Apply']))) : "";
@$fName = (isset($_POST['fName'])) ? (stripslashes(trim($_POST['fName']))) : "";
@$lName = (isset($_POST['lName'])) ? (stripslashes(trim($_POST['lName']))) : "";
@$pPhone = (isset($_POST['pPhone']) && preg_match("/^\d{3}[-\.]\d{3}[-\.]\d{4}$/", $_POST['pPhone'])) ? (stripslashes(trim($_POST['pPhone']))) : ""; // Verify phone number entries.
@$sPhone = (isset($_POST['sPhone']) && preg_match("/^\d{3}[-\.]\d{3}[-\.]\d{4}$/", $_POST['sPhone'])) ? (stripslashes(trim($_POST['sPhone']))) : ""; // Verify phone number entries.
$email = (isset($_POST['email']) && preg_match("/^\w(\.?[\w-])+@\w(\.?[\w-])+\.[a-z]{2,4}(\.[a-z]{2})?$/i", $_POST['email'])) ? (stripslashes(trim($_POST['email']))) : ""; // Verify email address entries.
@$password = (isset($_POST['password'])) ? (stripslashes(trim(@$_POST['password']))) : "";
@$cpass = (isset($_POST['cPassword'])) ? (stripslashes(trim($_POST['cPassword']))) : "";
@$s_Question = (isset($_POST['s_question'])) ? (stripslashes(trim($_POST['s_Question']))) : "";
@$qAnswer = (isset($_POST['qAnswer'])) ? (stripslashes(trim($_POST['qAnswer']))) : "";
@$uNumber = (isset($_POST['uNumber'])) ? intval(trim($_POST['uNumber'])) : 0;
@$bNumber = (isset($_POST['bNumber'])) ? intval(trim($_POST['bNumber'])) : 0;
@$rName = (isset($_POST['rName'])) ? (stripslashes(trim($_POST['rName']))) : "";
@$rType = (isset($_POST['rType'])) ? (stripslashes(trim($_POST['rType']))) : "";
@$cQuadrant = (isset($_POST['cQuadrant'])) ? (stripslashes(trim($_POST['cQuadrant']))) : "";
@$city = (isset($_POST['city']) && preg_match("/[^a-zA-Z]/i", $_POST['city'])) ? (stripslashes(trim($_POST['city']))) : "";
@$oCity = (isset($_POST['oCity']) && preg_match("/[^a-zA-Z]/i", $_POST['oCity'])) ? (stripslashes(trim($_POST['oCity']))) : "";
@$province = (isset($_POST['province']) && preg_match("/[^a-zA-Z]/i", $_POST['province'])) ? (stripslashes(trim($_POST['province']))) : "";
@$oProvince = (isset($_POST['oProvince']) && preg_match("/[^a-zA-Z]/i", $_POST['oProvince'])) ? (stripslashes(trim($_POST['oProvince']))) : "";
@$pCode = (isset($_POST['pCode'])) ? intval(trim($_POST['pCode'])) : 0;
@$childHome = (isset($_POST['childHome'])) ? (stripslashes(trim($_POST['childHome']))) : "";
@$noChild = (isset($_POST['noChild'])) ? (stripslashes(trim($_POST['noChild']))) : "";
@$fTwelve = (isset($_POST['fTwelve'])) ? (stripslashes(trim($_POST['fTwelve']))) : "";
@$sEighteen = (isset($_POST['sEighteen'])) ? (stripslashes(trim($_POST['sEighteen']))) : "";
@$uFive = (isset($_POST['uFive'])) ? (stripslashes(trim($_POST['uFive']))) : "";
@$tSixteen = (isset($_POST['tSixteen'])) ? (stripslashes(trim($_POST['tSixteen']))) : "";
@$member = (isset($_POST['member'])) ? (stripslashes(trim($_POST['member']))) : "";
@$payment = (isset($_POST['payment'])) ? (stripslashes(trim($_POST['payment']))) : "";
@$date = (function_exists('date')) ? date('d/m/Y') : "";
$_SESSION['apply'] = $apply;
$_SESSION['fName'] = $fName;
$_SESSION['lName'] = $lName;
$_SESSION['pPhone'] = $pPhone;
$_SESSION['sPhone'] = $sPhone;
$_SESSION['email'] = $email;
$_SESSION['password'] = $password;
$_SESSION['s_Question'] = $s_Question;
$_SESSION['qAnswer'] = $qAnswer;
$_SESSION['uNumber'] = $uNumber;
$_SESSION['bNumber'] = $bNumber;
$_SESSION['rName'] = $rName;
$_SESSION['rType'] = $rType;
$_SESSION['cQuadrant'] = $cQuadrant;
$_SESSION['city'] = $city;
$_SESSION['oCity'] = $oCity;
$_SESSION['province'] = $province;
$_SESSION['oProvince'] = $oProvince;
$_SESSION['pCode'] = $pCode;
$_SESSION['childHome'] = $childHome;
$_SESSION['noChild'] = $noChild;
$_SESSION['fTwelve'] = $fTwelve;
$_SESSION['sEighteen'] = $sEighteen;
$_SESSION['uFive'] = $uFive;
$_SESSION['tSixteen'] = $tSixteen;
$_SESSION['member'] = $member;
$_SESSION['payment'] = $payment;


if (empty($fName) || !preg_match("/[^a-zA-Z]/i", $fName) && $apply) {
echo "No First Name was entered."; // Verifys the first name entries.
} elseif (empty($lName) || !preg_match("/[^a-zA-Z]/i", $lName) && $apply) {
echo "No Last Name was entered."; // Verifys the last name entries.
} elseif (empty($password) && $apply) {
echo "No Password was entered.";
} elseif (empty($cpass) && $apply) {
echo "No Confirmation Password was entered.";
} elseif ($cpass != $password && $apply) {
echo "Confirmation password and password do not match.";
} elseif (empty($s_Question) || !preg_match("/[a-zA-Z0-9\.\,;:%&#@!\^-_~`\"'\[\]\{\}\*\/\?\(\)\n\r]/", $s_Question) && $apply) {
echo "No Secret question was entered."; // Verifys the secret question entries.
} elseif (empty($qAnswer) || !preg_match("/[a-zA-Z0-9\.\,;:%&#@!\^-_~`\"'\[\]\{\}\*\/\?\(\)\n\r]/", $qAnswer) && $apply) {
echo "No Answer was entered."; // Verifys the answer entries
} elseif (empty($bNumber) && $apply) {
echo "No building number was entered.";
} elseif (empty($rName) && $apply) {
echo "No Road Name was entered.";
} elseif (!preg_match("/^\d{5}(-\d{4})?$/", $pCode) || empty($code) && $apply) { // Verify US Postal Code entries.
echo "No postal Code was entered.";
} elseif (empty($member) && $apply) {
echo "You have not specified a member type.";
} elseif (empty($payment) && $apply) {
echo "You have not specified a Payment Type for your membership."; // Typo in text corrected.
} elseif ($payment == "Cash (Drop-Off)" && empty($email) || $payment == "Cheque / Money Order(Drop-Off)" && empty($email) || $payment == "Cheque / Money Order (Mail)" && empty($email) && $apply) {
$register->approval("regular", "decline");


} elseif ($payment == "Cash (Drop-Off)" && !empty($email) || $payment == "Cheque / Money Order(Drop-Off)" && !empty($email) || $payment == "Cheque / Money Order (Mail)" && !empty($email) && $apply) {
$register->approval("regularmail", "decline");


}
if (stripslashes(@$_POST['regular'])) {
echo "Thank you for your interest in applying to be a member. Your application has been put into cue for approval. You will be notified via telephone or regular mail if/when your membership is approved, and arrangements for payment will be made.";
$register->addMember();
} elseif (stripslashes(@$_POST['regularmail'])) {
$register->addMember();
echo "Thank you for your interest in applying to be a member. Your application has been put into cue for approval. You will be notified via email if/when your membership is approved, and arrangements for payment will be made.";
$message = "Thank you for your interest in applying to be a member. Your application has been put into cue for approval. You will be notified via email if/when your membership is approved, and arrangements for payment will be made.";
$from = "From: MRCA Administration";
mail($email, 'MRCA Membership Confirmation', '$message', '$from');
echo "Email sent successfully to $email!";
}
if (@$_POST['decline']) {
header("Location: join.php");
}


?>

stuffradio
03-25-2007, 11:17 PM
no matter what I do, it doesn't detect that text was entered in the firstName field

horizon
03-26-2007, 06:14 AM
Could you post what's in your joinfunction.php file ? I will take a look at it.

Burhan
03-26-2007, 07:03 AM
You can just put this one line:

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
/* rest of your code */
}

It should take care of most of your undefined index notices.

azizny
03-26-2007, 11:32 AM
Open php.ini:

replace error_reporting value with:


error_reporting = E_ALL & ~E_NOTICE; display all errors, warnings and notices


Peace,

TonyB
03-26-2007, 12:26 PM
Open php.ini:

replace error_reporting value with:


error_reporting = E_ALL & ~E_NOTICE; display all errors, warnings and notices


Peace,

Awful solution to the problem


To answer why those specific lines have the issue lets look at the PHP code here


$register = new Register();
@$apply = $_POST['Apply'];
@$fName = $_POST['fName'];
@$lName = $_POST['lName'];
@$pPhone = $_POST['pPhone'];
@$sPhone = $_POST['sPhone'];
$email = $_POST['email'];
@$password = @$_POST['password'];
@$cpass = $_POST['cPassword'];
@$s_Question = $_POST['s_Question'];
@$qAnswer = $_POST['qAnswer'];
@$uNumber = $_POST['uNumber'];
@$bNumber = $_POST['bNumber'];
@$rName = $_POST['rName'];
@$rType = $_POST['rType'];
@$cQuadrant = $_POST['cQuadrant'];
@$city = $_POST['city'];
@$oCity = $_POST['oCity'];
@$province = $_POST['province'];
@$oProvince = $_POST['oProvince'];
@$pCode = $_POST['pCode'];
@$childHome = $_POST['childHome'];
@$noChild = $_POST['noChild'];
@$fTwelve = $_POST['fTwelve'];
@$sEighteen = $_POST['sEighteen'];
@$uFive = $_POST['uFive'];
@$tSixteen = $_POST['tSixteen'];
@$member = $_POST['member'];
@$payment = $_POST['payment'];
@$date = date('d/m/Y');


An @ symbol tells PHP to ignore the error essentially. So if you look you're doing it on everything but the email part. Same idea with the errors on SQL both $_POST indexes are empty.

So all these errors are produced by the fact the $_POST array is empty. Why I do not know but that is why it's happening. There is already a solution to this problem above on checking if the values are set before assigning them to something.

stuffradio
03-26-2007, 06:12 PM
that's the whole reason for supressing errors for values. Although it finally all works now. I just need to integrate paypal in to my script.

Also do any of you know how to parse csv files with php? Need to do a huge database import, and one of the fields need to be seperated in to certain fields depending on the values of that field.

Burhan
03-27-2007, 01:49 AM
fgetcsv() (http://php.net/fgetcsv)

fgetcsv

(PHP 4, PHP 5)

fgetcsv — Gets line from file pointer and parse for CSV fields

That should help

mikey1090
03-27-2007, 04:49 AM
$_POST['email'] = "";

you need to define the array before assigning it a value dont you?

Saeven
03-27-2007, 11:51 AM
Aside from fyrestater's posts, these are just making bad code worse. Just use your variables inside of $_POST, there's no need to assign extra pointers to all those values in the script. Also, if you want some type of dynamic filtering, that will be a nightmare to maintain.

Consider something like this:

<?php

define( 'FILTER_NONE', 0 );
define( 'FILTER_NUM', 1 );
define( 'FILTER_EMAIL', 2 );
define( 'FILTER_PHONE', 3 );
// and so forth

function filterData( $value, $type ){
switch( $type ){
case FILTER_NUM:
return intval( $value );

//... write the others for email etc.


case FILTER_NONE:
default:
return htmlentities( trim( $value ) );
}
}

function getPost( $str ){
if( isset( $_POST[$str] ) )
return $_POST[$str];

return "";
}


$formvalues = array(
'Apply' => array( 'filter' => FILTER_NONE, 'session' => true, 'friendly' => 'apply' ),
'fName' => array( 'filter' => FILTER_NONE, 'session' => true, 'friendly' => 'first name' ),
// ....
'phone' => array( 'filter' => FILTER_PHONE, 'session' => true, 'friendly' => 'phone' )
);

// these two lines do what that huge block of filter code did
foreach( $_POST as $key => $value )
$_POST[$key] = filterData( $value, $formvalues[$key]['filter'] );

// store the session values that should be mirrored
foreach( $_POST as $key => $value )
if( $formvalues[$key]['session'] )
$_SESSION[$key] = $value;

try{
foreach( $formvalues as $key => $data )
if( !getPost( $key ) )
throw new Exception( $formvalues[$key]['friendly'];

// put your success login herein..
$register = new Register();

echo getPost( 'value' );


}
catch( Exception $e ){
echo "We're sorry, you need to fill out the {$e->getMessage()} field<br>";
}


This writ, make sure that your PHP environment variables include P, something like ECPGS, and that your post max size, permits the amount of data you are posting.

Hope this helps!
Alex

azizny
03-27-2007, 02:17 PM
Awful solution to the problem


It just happens that most hosting providers use that awful solution.

Peace,

TonyB
03-27-2007, 02:32 PM
It just happens that most hosting providers use that awful solution.

Peace,

And they also enable register_globals to be on and don't disable any of the dangerous PHP functions all in the name of being user friendly. Then in turn wonder why so many customer made scripts get exploited.


"Note: Enabling E_NOTICE during development has some benefits. For debugging purposes: NOTICE messages will warn you about possible bugs in your code. For example, use of unassigned values is warned. It is extremely useful to find typos and to save time for debugging. NOTICE messages will warn you about bad style. For example, $arr[item] is better to be written as $arr['item'] since PHP tries to treat "item" as constant. If it is not a constant, PHP assumes it is a string index for the array."

Sounds like something that should be on when you're developing something or do not know what you're doing. You can disable it along with any other error reporting at the script level when you aren't making changes on the fly.


Oh and a few posts above a PHP5 based solution those are a rarity :) try catch blocks are wonderful

Burhan
03-27-2007, 04:57 PM
Saeven, I liked the way you approached the problem. Its a bit of an update to what I would have done, I really like the way you approached it. I tip my hat to you.

stuffradio
03-27-2007, 06:00 PM
having a real problem with paypal right now.

I've looked at tons of websites and don't know where to start or how to implement it.

Here is what I want:
my Database:
-Date Paid
-Amount Paid
-Payment Received
-Persons name

3 yearly subscriptions

Credit Card payments

How do I implement this??

stuffradio
03-28-2007, 02:44 AM
Note:
Just found out the solution for paypal!

Go here:
https://www.paypal.com/IntegrationCenter/ic_ipn-pdt-variable-reference.html

Login to your paypal account....
go to merchants or something
go to IPN
set the url where it will go...
in the file of where you set it, put the post variables in that you want...
insert them in to your database if you want
pwnage