HDFilmMaker2112 Posted July 3, 2011 Share Posted July 3, 2011 The below is returning the error: The information you entered doesn\'t match the our for this account. Please try again. <br /> If you keep having problems, please contact us at <a href="mailto:general@makethemoviehappen.com"> general@makethemoviehappen.com This is triggered by the if statement with the ($_GET['e']==f) condition, in the form code. The database is pulling the proper information for the current person logged in as I checked with print_r on $donors_row. <?php session_start(); $myusername=$_SESSION['myusername2']; $mypassword=$_SESSION['mypassword2']; require_once 'db_select.php'; require_once 'func.php'; $select_donors="SELECT * FROM $tbl_name WHERE username='$myusername' AND password='$mypassword'"; $donors_results=mysql_query($select_donors); $donors_row=mysql_fetch_row($donors_results); $name=sanitize($_POST['name']); $email=sanitize($_POST['email']); $current_amount=amount_verify(sanitize($_POST['current_amount'])); $additional_amount=amount_verify(sanitize($_POST['additional_amount'])); $donor_id=$donors_row['donor_id']; if(email_verify($email)==$donors_row['email'] && $current_amount==$donors_row['amount'] && $name==$donors_row['name']){ $insert_additional="INSERT INTO $tbl_name3 (donor_id, additional_amount) VALUES ('$donor_id', '$additional_amount')"; $additional_results=mysql_query($insert_additional); mysql_fetch_row($additional_results); $message=' I would like to donate additional money to Make the Movie Happen. Name: '.$name.' Email: '.$email.' Additional Amount: '.$additional_amount.' '; mail('general@makethemoviehappen.com','Make the Movie Happen - Additional Donation', $message, 'From:' .$email.''); header('Location: ./index.php?usercp=donate&e=t'); } else{ header('Location: ./index.php?usercp=donate&e=f'); } ?> <?php $content=' <div class="main"> <div class="main_header">Donate Additional Money</div>'; if($_GET['e']==t){ $content.='<p class="green clear"> Request Sent. You should be contact with a donate button specifically for you, in the next two business days. </p> '; } else{ $content.=' <p> If you wish to donate additional money, use the form below to enter the additional amount you wish to donate, the name in which the credit is listed under (as listed on the donors page), and the e-mail address in which the original purchase came from. This is a great to get your name back on the top 100 donors list, and to bump up your contributor level, and thus the freebies you get in return. Once you submit this form, we will review the submitted material, create a new paypal donation button specifically for you, and send you the link to that button. From there, you will be able to make the additional donation.'; if($_GET['e']==f){ $content.='<p class="red"> The information you entered doesn\'t match the our for this account. Please try again. <br /> If you keep having problems, please contact us at <a href="mailto:general@makethemoviehappen.com"> general@makethemoviehappen.com</a>. </p>'; } $content.=' <form action="./additional_donate_email.php" method="post"> <p><label>Name Credit is Listed Under:</label> <input type="text" name="name" size="30" /></p> <p><label>E-Mail of Original Donation:</label> <input type="text" name="email" size="32" /></p> <p><label>Additional Donation Amount:</label> <input type="text" name="additional_amount" size="8" /></p> <p><label>Current Donation Amount:</label> <input type="text" name="current_amount" size="8" /></p> <p><input type="submit" value="Submit" name="Submit" /></p> </form> '; } $content.=" </div> <br />"; ?> func.php - Just in case you need to see what the functions are doing: function email_verify($email){ return preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $email); } function amount_verify($number){ $bits = explode(",",$number); // split input value up to allow checking $last = strlen($bits[1]); // gets part after first comma (thousands or decimals) if ($last < 3){ if ($last==0){ $number.=",00"; } $number = str_replace(".","",$number); $number = str_replace(",",".",$number); } $number = str_replace(",","",$number); $dec_bits = explode(".",$number); // split input value up to allow checking $dec = strlen($dec_bits[1]); // gets part first decimal point if ($dec==0){ $number.=".00"; } $symbol = substr($number, 0, 1); if(!ctype_digit($symbol)){ $number = substr($number, 1); } return $number; } It's clearly not meeting all the conditions in the form checking if statement. I'm just not sure why. Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/ Share on other sites More sharing options...
mikesta707 Posted July 3, 2011 Share Posted July 3, 2011 OK?... You've told us that your form is outputting something, and post4d some code (code which I don't see how it would output what you have posted) without indicating why this is wrong, and what you expect it to happen. you need to give more information. What did you do to get this response from your code. What do you expect to happen? Where is the code that produces this error? Please give more information, and in the future please be mindful of how you are asking questions. You can't just say "This isn't working", post some code, and expect to get an answer without telling us the circumstances in which this error was produced Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237800 Share on other sites More sharing options...
Pikachu2000 Posted July 3, 2011 Share Posted July 3, 2011 Since that error message seems to be tied to a conditional, my guess would be that this: if(email_verify($email)==$donors_row['email'] && $current_amount==$donors_row['amount'] && $name==$donors_row['name']){ is returning FALSE for some reason. Have you tried to debug this by echoing (or better yet, var_dump()ing) the values to see what is different? Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237802 Share on other sites More sharing options...
HDFilmMaker2112 Posted July 3, 2011 Author Share Posted July 3, 2011 Since that error message seems to be tied to a conditional, my guess would be that this: if(email_verify($email)==$donors_row['email'] && $current_amount==$donors_row['amount'] && $name==$donors_row['name']){ is returning FALSE for some reason. Have you tried to debug this by echoing (or better yet, var_dump()ing) the values to see what is different? I just did var_dump on the posted data after processing and print_r for $donors_row. Results returned: string(16) "Andrew McCarrick" string(29) "example@example.com" string( 8 ) "25000.00" string(9) "100000.00" Array ( [0] => 1 [1] => Andrew McCarrick [2] => 25000.00 [3] => Producer [4] => 4 [5] => example@example.com ) I'm noticing the array contains numbers as keys.... I'm trying to use the database table columns name, instead of the column number. Is this the issue? Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237803 Share on other sites More sharing options...
Pikachu2000 Posted July 3, 2011 Share Posted July 3, 2011 Yes. Change mysql_fetch_row() to mysql_fetch_assoc() if you want to use the associative keys. Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237805 Share on other sites More sharing options...
HDFilmMaker2112 Posted July 3, 2011 Author Share Posted July 3, 2011 Alright, it's got the associative keys now, but it still directs back to the form with the error. Makes me think the only other option, in the if statement, is this email_verify($email). That's the only one I can't check the result of, because it's not assigned to a variable. The only way that should not be working is if the preg_match is set-up wrong, correct? Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237806 Share on other sites More sharing options...
HDFilmMaker2112 Posted July 3, 2011 Author Share Posted July 3, 2011 Well I just checked the preg_match email_verify function by assigning it to a variable and adding it to var_dump, and it returns 1, which means it evaluates as true correct? EDIT: Here's the issue: if(email_verify($email)==$donors_row['email'] && $current_amount==$donors_row['amount'] && $name==$donors_row['name']){ Should be: if(email_verify($email) && $email==$donors_row['email'] && $current_amount==$donors_row['amount'] && $name==$donors_row['name']){ Now I'm curious, how can I redirect on a condition that the data was inserted into the database? Should I just do an if statement with the mysql_query as the condition? And I also have an issue with my amount processing function. When I type $1,000.00 it returns 100000.00. Ideas on why this is happening? Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237882 Share on other sites More sharing options...
wildteen88 Posted July 3, 2011 Share Posted July 3, 2011 The problem is to do with this line of code if(email_verify($email)==$donors_row['email'] There you are comparing the return value of email_verify() with a string value of the donors email address ($donors_row['email']). Your function email_verify() will only return true or false. This is where your code is failing and why you're being redirected back to index.php?usercp=donate&e=f and shown the error message. You cannot compare a boolean to a string. You should be checking to see if email_verifiy does not return false and that the variable $email is the same as $donors_row['email']. Change this line if(email_verify($email)==$donors_row['email'] && $current_amount==$donors_row['amount'] && $name==$donors_row['name']){ to if(email_verify($email) !== FALSE && $email == $donors_row['email'] && $current_amount==$donors_row['amount'] && $name==$donors_row['name']){ Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237883 Share on other sites More sharing options...
HDFilmMaker2112 Posted July 3, 2011 Author Share Posted July 3, 2011 Alright, that solves that. Now a few non-related issues: I'm curious, how can I redirect on a condition that the data was inserted into the database? Should I just do an if statement with the mysql_query as the condition? And I also have an issue with my amount processing function. When I type $1,000.00 it returns 100000.00. Ideas on why this is happening? It seems fine for other numbers, just $1,000.00. $1,001.00 and $2,000.00 don't replicate the same issue, just $1,000.00. Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237884 Share on other sites More sharing options...
wildteen88 Posted July 3, 2011 Share Posted July 3, 2011 I'm curious, how can I redirect on a condition that the data was inserted into the database? Should I just do an if statement with the mysql_query as the condition? You'd use mysql_affected_rows to see if your query inserted the record(s). And I also have an issue with my amount processing function. When I type $1,000.00 it returns 100000.00. Ideas on why this is happening? It seems fine for other numbers, just $1,000.00. I have tested your amount_verify() function and it returns $1,000.00 as 1000.00 for me. Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237885 Share on other sites More sharing options...
EdwinPaul Posted July 3, 2011 Share Posted July 3, 2011 Maybe this helps: http://php.net/manual/en/function.money-format.php Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237886 Share on other sites More sharing options...
HDFilmMaker2112 Posted July 3, 2011 Author Share Posted July 3, 2011 And I also have an issue with my amount processing function. When I type $1,000.00 it returns 100000.00. Ideas on why this is happening? It seems fine for other numbers, just $1,000.00. I have tested your amount_verify() function and it returns $1,000.00 as 1000.00 for me. Sorry my mistake, it's when I type $1000.00 or 1000.00 without the comma. That turns into 100000.00. Basically, when it's already properly formatted. I guess I need some way to by pass most of the function if it doesn't have a comma in it. I still need it to remove the symbol, if there is one present. So I can't by pass the entire function. Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237907 Share on other sites More sharing options...
HDFilmMaker2112 Posted July 3, 2011 Author Share Posted July 3, 2011 I used an if statement and checked to see if $bits[1] was empty: function amount_verify($number){ $bits = explode(",",$number); // split input value up to allow checking if(!empty($bits[1])){ $last = strlen($bits[1]); // gets part after first comma (thousands or decimals) if ($last < 3){ if ($last==0){ $number.=",00"; } $number = str_replace(".","",$number); $number = str_replace(",",".",$number); } $number = str_replace(",","",$number); } $dec_bits = explode(".",$number); // split input value up to allow checking $dec = strlen($dec_bits[1]); // gets part after first decimal point if ($dec==0){ $number.=".00"; } $symbol = substr($number, 0, 1); if(!ctype_digit($symbol)){ $number = substr($number, 1); } return $number; } Quote Link to comment https://forums.phpfreaks.com/topic/240981-form-giving-error/#findComment-1237939 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.