Need help on this Reg Error
Lets start things off by saying my register page works 100% Well not mine it was posted on Ragezone so im useing a basic one that some one scripted
My problem is it shows Notice: Undefined variable: error in C:\wamp\www\index.php on line 22 and
Notice: Undefined variable: error in C:\wamp\www\index.php on line 18
1.Users can register just fine
2.i even tryed ntwdblib.dll
3.Im useing WampServer
4.register Code look it over
Code:
<?php
$dns="GunzDB";
$user="sa";
$pass="MYPASS";
$connect=odbc_connect($dns, $user, $pass) or die ("Couldn't connect to the database, we're sorry...");
odbc_exec($connect,"use GunzDB");
function antisql($bericht){
$bericht = stripslashes($bericht);
$bericht = htmlspecialchars($bericht);
$bericht = nl2br($bericht);
return $bericht;
}
if(isset($_GET['action']) AND $_GET['action'] == "register"){
if(empty($_POST['username'])){
$error.="No username filled!<br>";
}
if(empty($_POST['password'])){
$error.="No password filled!<br>";
}
if(empty($_POST['email'])){
$error.="No e-mail filled!<br>";
}
if(empty($_POST['name'])){
$error.="No name filled!<br>";
}
if(empty($_POST['age'])){
$error.="No age filled!<br>";
}
if($error == TRUE){
echo "<br><br><center>There are some troubles while registering your account:<br>".$error."</center><br>";
die();
}
else
{
$regdate = date("Y-m-d H:i:s");
$email = antisql($_POST['email']);
$reg = "INSERT INTO Account (UserID, UGradeID, PGradeID, RegDate, Email, Age, Name) VALUES ('".antisql($_POST['username'])."', '1', '1', '$regdate', '$email', '".antisql($_POST['age'])."', '".antisql($_POST['name'])."')";
$query = odbc_exec($connect,$reg);
$gebruiker1 = "SELECT AID FROM Account WHERE UserID='".antisql($_POST['username'])."'";
$gebruiker = odbc_exec($connect,$gebruiker1);
$i=1;
while (odbc_fetch_row($gebruiker, $i)){
$aid = odbc_result($gebruiker, 'AID');
$i++;
}
if (!$aid)
{
die ("Oeps, something's wrong with the database");
}
$reg2 = "INSERT INTO Login (UserID, AID, Password) VALUES ('".antisql($_POST['username'])."', '$aid', '".antisql($_POST['password'])."')";
$query = odbc_exec($connect,$reg2);
print ("<center>Your account is succesfully created!</center>");
}
}
?><style type="text/css">
<!--
body {
background-color: #000099;
background-image: url(http://rpgwallpaper.com/wallpapers/gunz-online-3-1280x1024.jpg);
background-repeat: repeat-x;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body,td,th {
color: #E56717;
font-size: large;
}
.top {
background-position: top;
}
.style1 {
background-image: url(http://up201.siz.co.il/up1/mz3wugdn2tmy.jpg);
background-repeat: repeat;
background-position: center top;
height: 414px;
width: 248px;
clear: none;
float: none;
font-size: 18px;
}
.style2 {font-size: 18px}
-->
</style>
<center>
<div align="center" class="style2"><b>Gunz Register Page:</b><br>
<strong>Have Fun In Gunz</strong><br>
<?php echo "<form action='".$_SERVER['PHP_SELF']."?action=register' method='POST'>"; ?></div>
<tr>
<td height='24' align=center class="style2"> </td>
</tr><tr><td height='24' align=center class="style2"> </td>
<td height='24' align=center class="style2"> </td>
</tr>
<span class="style2"><br>
</span>
<tr>
<td height='24' align=center class="style2"></td>
<td height='24' align=center class="style2"></td>
</tr>
<span class="style2"><br>
</span>
<tr>
<td height='24' align=center class="style2"></td>
<td height='24' align=center class="style2"></td>
</tr>
<table width="220" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="424" align="center" class="style1"><p><br />
Username</p>
<p>
<input type='text' name='username' />
</p>
<p>Password</p>
<p>
<input type='password' name='password' />
</p>
<p>E-mail</p>
<p>
<input type='text' name='email' />
</p>
<p>Name</p>
<p>
<input type='text' name='name' />
</p>
<p>Age</p>
<p>
<input type='text' name='age' />
</p>
<p> </p></td>
</tr>
</table>
<p align="center" class="style2">
<input type='submit' value='Register!' />
</p>
<p align="center" class="style2"></p>
Re: Need help on this Reg Error
you are missing the instance server.
Re: Need help on this Reg Error
how do i go about doing/getting/fixing that?
Re: Need help on this Reg Error
is $error defined in functions?
Re: Need help on this Reg Error
The following works on my localhost with XAMPP. (ODBC connect part wasn't right I guess.)
PHP Code:
<?php
$host = 'PCNAME\SQLEXPRESS'; //host
$dbname = 'GunzDB'; //db name
$user = ''; //username
$pass = ''; //password
$connect = odbc_connect("Driver={SQL Server}; Server={$host}; Database={$dbname}", $user, $pass) or die("Cannot Connect to MSSQL Server Please check config settings");
function antisql($bericht)
{
$bericht = stripslashes($bericht);
$bericht = htmlspecialchars($bericht);
$bericht = nl2br($bericht);
return $bericht;
}
if(isset($_GET['action']) AND $_GET['action'] == "register"){
if(empty($_POST['username'])){
$error.="No username filled!<br>";
}
if(empty($_POST['password'])){
$error.="No password filled!<br>";
}
if(empty($_POST['email'])){
$error.="No e-mail filled!<br>";
}
if(empty($_POST['name'])){
$error.="No name filled!<br>";
}
if(empty($_POST['age'])){
$error.="No age filled!<br>";
}
if($error == TRUE){
echo "<br><br><center>There are some troubles while registering your account:<br>".$error."</center><br>";
die();
}
else
{
$regdate = date("Y-m-d H:i:s");
$email = antisql($_POST['email']);
$reg = "INSERT INTO Account (UserID, UGradeID, PGradeID, RegDate, Email, Age, Name) VALUES ('".antisql($_POST['username'])."', '1', '1', '$regdate', '$email', '".antisql($_POST['age'])."', '".antisql($_POST['name'])."')";
$query = odbc_exec($connect,$reg);
$gebruiker1 = "SELECT AID FROM Account WHERE UserID='".antisql($_POST['username'])."'";
$gebruiker = odbc_exec($connect,$gebruiker1);
$i=1;
while (odbc_fetch_row($gebruiker, $i)){
$aid = odbc_result($gebruiker, 'AID');
$i++;
}
if (!$aid)
{
die ("Oeps, something's wrong with the database");
}
$reg2 = "INSERT INTO Login (UserID, AID, Password) VALUES ('".antisql($_POST['username'])."', '$aid', '".antisql($_POST['password'])."')";
$query = odbc_exec($connect,$reg2);
print ("<center>Your account is succesfully created!</center>");
}
}
?><style type="text/css">
<!--
body {
background-color: #000099;
background-image: url(http://rpgwallpaper.com/wallpapers/gunz-online-3-1280x1024.jpg);
background-repeat: repeat-x;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body,td,th {
color: #E56717;
font-size: large;
}
.top {
background-position: top;
}
.style1 {
background-image: url(http://up201.siz.co.il/up1/mz3wugdn2tmy.jpg);
background-repeat: repeat;
background-position: center top;
height: 414px;
width: 248px;
clear: none;
float: none;
font-size: 18px;
}
.style2 {font-size: 18px}
-->
</style>
<center>
<div align="center" class="style2"><b>Gunz Register Page:</b><br>
<strong>Have Fun In Gunz</strong><br>
<?php echo "<form action='".$_SERVER['PHP_SELF']."?action=register' method='POST'>"; ?></div>
<tr>
<td height='24' align=center class="style2"> </td>
</tr><tr><td height='24' align=center class="style2"> </td>
<td height='24' align=center class="style2"> </td>
</tr>
<span class="style2"><br>
</span>
<tr>
<td height='24' align=center class="style2"></td>
<td height='24' align=center class="style2"></td>
</tr>
<span class="style2"><br>
</span>
<tr>
<td height='24' align=center class="style2"></td>
<td height='24' align=center class="style2"></td>
</tr>
<table width="220" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="424" align="center" class="style1"><p><br />
Username</p>
<p>
<input type='text' name='username' />
</p>
<p>Password</p>
<p>
<input type='password' name='password' />
</p>
<p>E-mail</p>
<p>
<input type='text' name='email' />
</p>
<p>Name</p>
<p>
<input type='text' name='name' />
</p>
<p>Age</p>
<p>
<input type='text' name='age' />
</p>
<p> </p></td>
</tr>
</table>
<p align="center" class="style2">
<input type='submit' value='Register!' />
</p>
<p align="center" class="style2"></p>