Hello guys, im pretty new @ php and mysql and i have a project for my university to create an eshop site.
Im coding this project for quite a long time and today i kind of finished it, although i encountered some critical errors. It seems that my php code for mysql queries doesnt seem to work properly…If i give the same queries at mysql console its all fine, but with commands nothings works at all.I checked my code loads and loads of time and i cant understand what is wrong with it. If someone could help me cause my deadline is soon i would apreaciate it
Here is my code:
[php]<?php
include(‘credentials.php’);
ini_set(‘display_errors’, ‘On’);
if (isset($_POST[‘username’]) && isset($_POST[‘password’]) ) {
$username= $_POST[‘username’];
$password= $_POST[‘password’];
$email= $_POST[‘email’];
$link=@mysqli_connect(“localhost”,$dbuser,$dbpass,$dbname);
if (mysqli_connect_errno()){
echo “Error at DB connection”;
echo mysqli_connect_error();
exit();
}
$query = “INSERT INTO users VALUES(’$username’,’$password’,’$email’,‘0’,‘null’,‘null’,‘null’)”;
mysqli_query($link,$query);
if ( mysqli_errno()) {
$error= mysqli_error();
header(“location: index.php?msg=$error”);
echo $error;
}
else {
header(“location: auth.php?msg=Need to authenticate thro your email dude”);
}
mysqli_close($link);
}
?>
[/php]
and the code from the form:
<body>
<div id="container">
<div id="header">
<p class="top"> <strong> Dark Side Buisness Controller </strong> </p>
</div>
<div id="menu">
<ul>
<li><a href="index.php"> Home Page </a></li>
<li><a href="about.php"> About US </a></li>
<li><a href="register.php"> Register </a></li>
<li><a href="login.php"> Login </a><li>
<?php if ( isset($_SESSION)) { ?>
<li><a href="control.php"> Control Panel</a><li>
<li><a href="upload.php"> Upload </a><li>
<li><a href="logout.php"> Logout</a><li>
<?php
}
?>
</ul>
</div>
<div id="main">
<div id="formcontainer">
<form id="data" name="data" action="connection.php" method="POST">
<table width="100%" cellpadding="3" cellspacing="2">
<tr>
<td width="25%"> </td>
</tr>
<tr>
<td class="right" width="20%"> <strong> Username </strong> </td>
<td>
<input type="text" name="username" id="username" size="25" maxlength="25"/>
</td>
</tr>
<tr>
<td class="right"> <strong> Password</strong> </td>
<td>
<input type="password" name="password" id="password" size="25" maxlength="25"/>
</td>
</tr>
<tr>
<td class="right"> <strong> Email</strong> </td>
<td>
<input type="text" name="email" id="email"/>
</td>
</tr>
<tr>
<td>
<input name="reset" type="reset" id="reset" value="Reset" />
<input name="submit" type="submit" id="submit" value="Submit" />
</td>
</tr>
</table>
</form>
</div>
</div>
<div id="footer">
<p>© 2012 - ΤΕΙ Λάρισας</p>
</div>
</div>
</body>
</html>