Rifts Posted November 11, 2009 Share Posted November 11, 2009 I have a form which asks a few questions I want the answers to be stored in the column s associated with that specific user who submitted them. The first part is the html form and the second is the exec.php script.. I dont know whats wrong? I guess that code for the form isnt that important I just posted it incase you needed vars names? i dont know thanks <form id="loginForm" name="loginForm" method="post" action="domainform-exec.php"> <table width="350" border="0" align="center" cellpadding="4" cellspacing="10"> <tr> <th>Description of Website:</th> <td><textarea name="description" rows="2" cols="20"></textarea></td> </tr> <tr> <th>Prefered Extension: </th> <td><input type="checkbox" name="chk1" value="com"> .Com <input type="checkbox" name="chk2" value="net"> .Net <br /><input type="checkbox" name="chk3" value="org"> .Org <input type="checkbox" name="chk4" value="any"> Any <br></td> </tr> <tr> <th width="124">Associated Keywords:</th> <td width="168"><input name="keyword" type="text" class="textfield" id="keyword" /></td> </tr> <tr> <th>Dashes are:</th> <td><select name="dashes"> <option value="ok">OK</option> <option value="notok">NOT OK</option> </select></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit Now" /></td> </tr> </table> </form> and heres the actually exec.php <?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $description = clean($_POST['description']); $keyword = clean($_POST['keyword']); //Create INSERT query $qry1 = "INSERT INTO members(user, description) VALUES('".$_SESSION['SESS_MEMBER_ID']."','$description')"; $result = @mysql_query($qry1); //Check whether the query was successful or not if($result) { header("location: google.com"); exit(); }else { die("Query failed"); } ?> Link to comment https://forums.phpfreaks.com/topic/181188-storing-user-data/ Share on other sites More sharing options...
BoarderLine Posted November 12, 2009 Share Posted November 12, 2009 Hi Rifts, Whats actually happening when you submit the form? You are calling the php page exec.php however your form action is domainform-exec.php? Also just a wild stab, have you also tried adding id's to your form fields. Link to comment https://forums.phpfreaks.com/topic/181188-storing-user-data/#findComment-955893 Share on other sites More sharing options...
Rifts Posted November 12, 2009 Author Share Posted November 12, 2009 yeah sorry i just called it exec.php for easy typing and when I submit it says "Query failed" I think the problem is I cant not figure out how to add the submitted data into the column based on the user who is logged in. Link to comment https://forums.phpfreaks.com/topic/181188-storing-user-data/#findComment-955894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.