dropfaith Posted January 25, 2009 Share Posted January 25, 2009 im sure i cant be too far off but this doesnt work properly i submits to the database no matter what <input type="hidden" name="referral" value="ImagesByTroy" />would submit the form to the database but <input type="hidden" name="referral" value="" />Would not referral is a hidden form field that uses get from the previous page to populate <?php if(!is_array($_GET['referral'])) { include("../client/header.php"); // set up error list array $errorList = array(); $count = 0; // validate text input fields $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $Earned = $_REQUEST['Earned'] ; $Billed = $_POST['Billed']; $Name = $_REQUEST['name']; $Referral = $_REQUEST['referral']; $Email = $_POST['email']; // check for errors // if none found... // generate and execute query $query = "INSERT INTO referrals (Referral, Name, Billed, Earned, Email) VALUES('$Referral','$Name','0','0','$Email')"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); echo "<p>Update successful.<a href=index.php>Go Home</a>.<br /></p>"; // close database connection mysql_close($connection); } else { //special circumstance } // includes ?> Link to comment https://forums.phpfreaks.com/topic/142313-solved-if-get-returns-result-insert-to-db-else-do-not/ Share on other sites More sharing options...
Philip Posted January 25, 2009 Share Posted January 25, 2009 Change: if(!is_array($_GET['referral'])) to: if(isset($_GET['referral']) && !empty($_GET['referral'])) Link to comment https://forums.phpfreaks.com/topic/142313-solved-if-get-returns-result-insert-to-db-else-do-not/#findComment-745692 Share on other sites More sharing options...
9three Posted January 25, 2009 Share Posted January 25, 2009 Do not forget to use mysql_real_escape_string to avoid SQL Injections. Link to comment https://forums.phpfreaks.com/topic/142313-solved-if-get-returns-result-insert-to-db-else-do-not/#findComment-745696 Share on other sites More sharing options...
dropfaith Posted January 25, 2009 Author Share Posted January 25, 2009 Do not forget to use mysql_real_escape_string to avoid SQL Injections. yeah i know i just tagged the code up to demonstrate what i was attemptin g to do better explaining was too hard thatnks tho Link to comment https://forums.phpfreaks.com/topic/142313-solved-if-get-returns-result-insert-to-db-else-do-not/#findComment-745701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.