So, while I was trying to get some data into my database, I came across this problem, of which I have no clue how to fix it. It just gives no output at all. I am a total newbie to php and database registering. I am able to do some sql.
Also, while I was testing some stuff I came to the conclusion that when I have a small database(just user, email and password) I am able to insert some data into the database. That's why I made two separate databases.
Info about the db: - Called datingsite - two tables: 'User' and 'Eigenschappen' - Both tables have a 'Lidnummer'(INT. Max 255) and set to index and AI
I am using portable xampp 1.8.3
Code:
Connect.php:
<?php
$connection = mysqli_connect('localhost', 'root', '');
if (!$connection){
die("Database Connection Failed" . mysql_error());
}
$select_db = mysqli_select_db($connection,'datingsite');
if (!$select_db){
die("Database Selection Failed" . mysql_error());
}
?>
Register.php:
<?php
require('connect.php');
/* If the values are posted, insert them into the database.
$sql = "SELECT * FROM `user`";
$res = mysql_query($sql);
$row = mysql_fetch_array($res) or die(mysql_error());
echo $row['email']. " - ". $row['wachtwoord'];*/
if (isset($_POST['email']) && isset($_POST['wachtwoord'])){
$email = $_POST['email'];
$wachtwoord = $_POST['wachtwoord'];
$Voornaam = $_POST['Voornaam'];
$Tweedenaam = $_POST['Tweedenaam'];
$Achternaam = $_POST['Achternaam'];
$Ben = $_POST['Ben'];
$Zoek = $_POST['Zoek'];
$Woonplaats = $_POST['Woonplaats'];
$Provincie = $_POST['Provincie'];
$Hobby1 = $_POST['Hobby1'];
$Hobby2 = $_POST['Hobby2'];
$Dag = $_POST['Dag'];
$Maand = $_POST['Maand'];
$Jaar = $_POST['Jaar'];
$Opleiding = $_POST['Opleiding'];
$query = "INSERT INTO 'user' ('Email', 'Wachtwoord', 'Voornaam', 'Tweedenaam', 'Achternaam', 'Ben', 'Zoek', 'Ingelogd')
VALUES (
'$email',
'$wachtwoord',
'$Voornaam',
'$Tweedenaam',
'$Achternaam',
'$Ben',
'$Zoek')";
$query2 = "INSERT INTO 'Eigenschappen' ('Woonplaats', 'Provincie', 'Hobby1', 'Hobby2', 'Dag', 'Maand', 'Jaar', 'Opleiding')
VALUES (
'$Woonplaats',
'$Provincie',
'$Hobby1',
'$Hobby2',
'$Dag',
'$Maand',
'$Jaar',
'$Opleiding')";
$result = mysql_query($query);
$res = mysql_query($query2);
if(($result)&($res)){
$msg = "User Created Successfully.";
}
}
?>
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="utf-8" />
<title>Registreren op Chives</title>
<link href="../Css/inlog.css" rel="stylesheet"/>
<link href="../Css/styles.css" rel="stylesheet" />
</head>
<body class="back">
<?php
if(isset($msg) & !empty($msg)){
echo $msg;
}
?>
<div id="Inlog-Container" align="center">
<form action="" method="post">
<H1> Registreren </H1>
<H2> Email:</H2>
<input name="email" type="email" class="Input-box" required/>
<H2> Wachtwoord:</H2>
<input name="wachtwoord" type="password" class="Input-box" required/>
<div class="Radiolabelbox">
<fieldset class="" id="" >
<H2>Ik ben een:</H2>
<div class="Radiolabel">
<label>
<input type="radio" name="Ben" class="styled-radio" value="Man" required/>
Man
</label> <br />
<label>
<input type="radio" name="Ben" class="styled-radio" value="Vrouw"/>
Vrouw
</label>
</div>
</fieldset>
<fieldset class="">
<H2 class="">Ik zoek een:</H2>
<div class="Radiolabel">
<label>
<input type="radio" name="Zoek" class="styled-radio" value="Man" required/>
Man
</label>
<br />
<label>
<input type="radio" name="Zoek" class="styled-radio" value="Vrouw"/>
Vrouw
</label>
<br />
<label>
<input type="radio" name="Zoek" class="styled-radio" value="Beide"/>
Beide
</label>
</div>
</fieldset>
</div>
<H2> Woonplaats:</H2>
<input name="Woonplaats" type="text" class="Input-box" required/>
<H2> Provincie:</H2>
<input name="Provincie" type="text" class="Input-box" required/>
<H2> Hobby 1:</H2>
<input name="Hobby1" type="text" class="Input-box" required/>
<H2> Hobby 2:</H2>
<input name="Hobby2" type="text" class="Input-box" required/>
<H2> Voornaam:</H2>
<input name="Voornaam" type="text" class="Input-box" required/>
<H2> Tweede naam:</H2>
<input name="Tweedenaam" type="text" class="Input-box" required/>
<H2> Achternaam:</H2>
<input name="Achternaam" type="text" class="Input-box" required/>
<H2> Geboortedag:</H2>
<input name="Dag" type="Number" class="Input-box" min="0" max="31" required/>
<H2> Geboortemaand:</H2>
<input name="Maand" type="Number" class="Input-box" min="0" max="12" required/>
<H2> Geboortejaar:</H2>
<input name="Jaar" type="Number" class="Input-box" min="1920" max="2000" required/>
<H2> Opleiding:</H2>
<input name="Opleiding" type="Text" class="Input-box" required/>
<input type="submit" value="GA VERDER" class="Roundbutton" id="Login" />
</form>
</div>
</body>
</html>
How can I get to fix my code so I can register into my database?
Any help is appreciated! Thanks in advance!
Ps. I'm sorry for the fact that most of the text in my code is in dutch.