form problem
Posted on
16th Feb 2014 07:03 pm by
admin
Hi all, I think this is going to be easy to resolve but for I have been looking at it to long and I cannot see my issue!
I hope this is in the right section as it uses modalbox, however I think its a php error not modalbox.
Basically I have a registration form as follows:
Code: <form action="pages/reg_do.php" id="myform" onsubmit="return false;">
<fieldset>
<legend>Register New User</legend>
<table>
<tr>
<td><label for="name"><strong>Username </strong></label></td>
<td> </td>
<td><input type="text" size="30" id="username" name="username" /></td>
</tr>
<tr>
<td><label for="password"><strong>Password </strong></label></td>
<td> </td>
<td><input type="text" size="30" id="password" name="password" /></td>
</tr>
<tr>
<td><label for="email"><strong>Email</strong></label></td>
<td> </td>
<td><input type="text" size="30" id="email" name="email" /></td>
</tr>
<tr>
<td> <label for="first_name"><strong>First Name</strong></label></td>
<td> </td>
<td><input type="text" size="30" id="first_name" name="first_name" /></td>
</tr>
<tr>
<td><label for="last_name"><strong>Last Name</strong></label></td>
<td> </td>
<td><input type="text" size="30" id="last_name" name="last_name" /></td>
</tr>
<tr>
<td><label for="city"><strong>City</strong></label></td>
<td> </td>
<td><input type="text" size="30" id="city" name="city" /></td>
</tr>
<tr>
<td><label for="state"><strong>State</strong></label></td>
<td> </td>
<td><select name="state">
<option value="WA">Western Australia</option>
<option value="SA">Southern Australia</option>
<option value="VIC">Victoria</option>
<option value="NT">Nothern Territories</option>
<option value="TAS">Tasmania</option>
<option value="QLD">Queensland</option>
</select></td>
</tr>
</table>
</fieldset>
<p><input type="submit" value="Register" onclick="Modalbox.show('pages/reg_do.php', {title: 'Registering....', width: 500, params:Form.serialize('myform') }); return false;" /> or <a href="#" title="Cancel & close dialog" onclick="Modalbox.hide(); return false;">Cancel & close</a></p>
</form>
</body>
</html>
This is opened from the main page in a modalbox popup box, once the form is submitted it goes to red_do.php, which loads in a replacement modalbox:
Code: <?php
session_start();
include '../common/dbconnect.php';
$username = $_GET['username'];
$password = $_GET['password'];
$first_name = $_GET['first_name'];
$last_name = $_GET['last_name'];
$email = $_GET['email'];
$city = $_GET['city'];
$state = $_GET['state'];
$query = 'INSERT INTO users (user_id, username, password)
VALUES ("", "$username", "$password")';
$result = mysql_query($query, $conn) or die(mysql_error());
$user_id = mysql_insert_id($conn);
$query = 'INSERT INTO users_details
(user_id, username, first_name, last_name, email, city, state)
VALUES
("$user_id","$username", "$first_name", "$last_name", "$email", "$city", "$state") ';
$result = mysql_query($query, $conn) or die(mysql_error());
$_SESSION['logged'] = 1;
$_SESSION['username'] = $username;
echo "thankyou, working";
?>
I then get the thankyou message, however instead of submitting the actual values into the database it will physically submit $username as apposed to the value of $username.
What am I missing.
As a sidenote, i understand the importance of escaping strings and this is done in the database connect file using:
Code: foreach ($_POST as $key => $value) {
$_POST[$key] = mysql_real_escape_string($value);
}
foreach ($_GET as $key => $value) {
$_GET[$key] = mysql_real_escape_string($value);
}
as I know people like pointing this out
215
20
Other php-forum
gmdate() - want 1 hr before time
Hi,
I am using php gmdate().
Now I am entering all dates in my dbase using gmdate("Y-m-d
Paypal
Hi all,
I have an advanced basic knowledge of php
I want to try something new for a s
php redirecting
i wont open a new thread but i have a question about redirecting....
i wonder why my code doesnt
multipart emiail forms
Hi All,
I am new to the boards and I've been working on a form (which is rather massive, imo
Secure pages Sessions vs. Cookies & session_destroy() help
Im new here and new to PHP, I hope you can help me with some questions.
Im writing my web ap
frames get header location..
i have two frames, one top, one bottom. how do i do a form on the bottom frame that gives me the ur
how to use two buttons with php
hi i have one form. there are three fields which are to be filled by the user. and then there are tw
DateTimeZone::listIdentifiers headache
http://php.net/manual/en/datetimezone.listidentifiers.php
So the documentation states tha
Problem with shopcart code
Hello, I am having a bit of trouble being able to add a product to my shopcart. My mysql database i
PHP/PKI
I am trying to set up a web application that uses pki. does anyone have a good tutorial to set this