Menu
im having problems getting a mysql query to add data to a table.
[code=php]
<?php
$db = mysql_connect(“localhost”,”autowar”,”password”) or
die(“Unable to connect to the server. Please try again later.”);
mysql_select_db(“autowar_uk_db”,$db);
$query=”INSERT INTO details (uname,pword,email) VALUES ($uname,$pword,$email)”;
$result=mysql_query($query) or die(“There was an error, possibly because the server is overloaded or because Jacob couldn’t code a turtle.”);
mysql_close();
?>
the $uname, $pword and $email vars are the names of the text boxes in the form that this script is the action of
[code=php]
<?php
$db = mysql_connect("localhost","autowar","password") or
die("Unable to connect to the server. Please try again later.");
mysql_select_db("autowar_uk_db",$db);
$query="INSERT INTO 'details' ('uname','pword','email') VALUES ('$uname','$pword','$email')";
$result=mysql_query($query) or die("There was an error, possibly because the server is overloaded or because Jacob couldn't code a turtle.");
mysql_close();
?>[/code]
[CODE]
_____
oo/><><>
( -)><><><>
L|_|L|_|`[/CODE]
<i>
</i><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Autowar SignUp</title>
<style type="text/css">
<!--
label {display:block; margin:1em 0eml; text-align:right}
input {margin:0em 1ex}
fieldset {padding:1em}
legend {font-weight:bold}
-->
</style>
<script type="text/javascript">
<!--
String.prototype.isEmailAddress = function () {return this.match(/^[^x00-x20()<>@,;:\".[]x7f-xff]+(?:.[^x00-x20()<>@,;:\".[]x7f-xff]+)*@[^x00-x20()<>@,;:\".[]x7f-xff]+(?:.[^x00-x20()<>@,;:\".[]x7f-xff]+)+$/)}
function validate(f) {
if (f.agree.checked==false){alert('You must agree to the terms and conditions'); f.agree.focus(); return false};
if (!/S/.test(f.uname.value)) {alert ('You must enter a User Name.'); f.uname.focus(); return false};
if (!/S/.test(f.pword.value)) {alert ('You must enter a Password.'); f.pword.focus(); return false};
if (!/S/.test(f.conpword.value)) {alert ('You must confirm your password.'); f.conpword.focus(); return false};
if (f.conpword.value != f.pword.value) {alert ('Your passwords much match.'); f.conpword.focus(); return false};
if (!/S/.test(f.email.value)) {alert ('You must enter a valid email address.'); f.email.focus(); return false};
if (!/S/.test(f.conemail.value)) {alert ('You must confirm your email address.'); f.conemail.focus(); return false}; <br/>
if (f.conemail.value != f.email.value) {alert ('Your email addresses must match.'); f.conemail.focus(); return false};
}
// -->
</script>
<div align="center">
<form action="signup.php" onsubmit="return validate(this)">
<div style="width:25em">
<fieldset>
<legend>Terms & Conditions</legend>
<textarea rows="10" cols="40">1. I will not attempt to hack another username or gain enrtry to the server.
2. I will not use the game as a way of sending offencive messages with mallicious intent.
3. I will not create more than one account.
4. I agree to having my IP banned from playing the game by the webmaster for a good reason.
5. I will not copy, reproduce or sell this game in any way.
</textarea>
<labe style="text-align:center"><input type=checkbox name="agree">I agree to the AutoWar Terms & Conditions<label>
</fieldset>
<fieldset>
<legend>Register</legend>
<label>User Name:<input type="text" size="20" name="uname"></label>
<label>Password:<input type="password" size="20" name="pword"></label>
<label>Confirm Password:<input type="password" size="20" name="conpword"></label>
<label>Email Address:*<input type="text" name="email" onchange="if (!this.value.isEmailAddress()) {alert ('That would not appear to be a valid email address.'); this.value=''; this.focus()}"></label>
<label>Confirm Email Address:*<input type="text" name="conemail" onchange="if (!this.value.isEmailAddress()) {alert ('That would not appear to be a valid email address.'); this.value=''; this.focus()}"></label>
*Must be correct
</fieldset>
<div style="text-align:center"><br>
<button type="submit">Sign Up</button>
</div>
</form>
</div>
</html>
[code=php]
<?php
$db = mysql_connect("localhost","autowar","password") or
die("Unable to connect to the server. Please try again later.");
mysql_select_db("autowar_uk_db",$db);
$query="INSERT INTO 'details' ('uname','pword','email') VALUES ($uname,$pword,$email)";
$result=mysql_query($query) or die("There was an error, possibly because the server is overloaded or because Jacob couldn't code a turtle.");
mysql_close();
?>
[/code]
[code=php]
<?php
$db = mysql_connect("localhost","epicgame","biffyclyro") or
die("Unable to connect to the server. Please try again later.");
mysql_select_db("epicgame_uk_db",$db);
$query="INSERT INTO 'epic' ('uname','pword','email') VALUES ($uname,$pword,$email)";
$result=mysql_query($query) or die("There was an error, possibly because the server is overloaded or because Jacob couldn't code a turtle.");
mysql_close();
?>
[/code]
[code=php]$query="INSERT INTO 'epic' ('uname','pword','email') VALUES ($uname,$pword,$email)";[/code]
as [code=php]$query="INSERT INTO epic
(uname
,pword
,email
) VALUES ('$uname','$pword','$email')";[/code]
[code=php]$uname = $_POST['uname'];
$pword = $_POST['pword'];
$email = $_POST['email'];[/code]
[code=php]
<?php
$uname = $_POST['uname'];
$pword = $_POST['pword'];
$email = $_POST['email'];
$db = mysql_connect("localhost","epicgame","biffyclyro") or
die("Unable to connect to the server. Please try again later.");
mysql_select_db("epicgame_uk_db",$db);
$query="INSERT INTO 'epic' ('uname','pword','email') VALUES ($uname,$pword,$email)";
mysql_query($query) or die("There was an error, possibly because the server is overloaded or because Jacob couldn't code a turtle.");
mysql_close();
?>
[/code]
[code=php]$query="INSERT INTO epic
(uname
,pword
,email
) VALUES ('$uname','$pword','$email')";[/code]
[code=php]$query="INSERT INTO epic
(uname
,pword
,email
) VALUES ('".$uname."','".$pword."','".$email."')";[/code]
0.1.9 — BETA 6.16