Jump to content

storing user data


Rifts

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.