This question already has answers here:
Can I mix MySQL APIs in PHP?
(4 answers)
Closed 6 years ago.
Hello Im trying to make my signup page check if a username or email is already in use. But it just goes over the code like its not their and before you mark this as a dupe of Check if username already exists using PHP I've already went over there and i tried the fix their but i didn't work so at this point I'm clueless I've tried every thing i know!
HTML for the sign up page
<?php
session_start();
include 'header.php';
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strpos($url, 'error=username') !== false) {
echo "<div class='transition' style='height: 20px; background-color: #ff6b66; text-align: center; margin-top: 30px; margin-right: 40%; margin-left: 40%; border-radius: 20px; padding: 5px;'>Fill out username box!</div>";
}
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strpos($url, 'error=password') !== false) {
echo "<div class='transition' style='height: 20px; background-color: #ff6b66; text-align: center; margin-top: 30px; margin-right: 40%; margin-left: 40%; border-radius: 20px; padding: 5px;'>Fill out password box!</div>";
}
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strpos($url, 'error=first') !== false) {
echo "<div class='transition' style='height: 20px; background-color: #ff6b66; text-align: center; margin-top: 30px; margin-right: 40%; margin-left: 40%; border-radius: 20px; padding: 5px;'>Fill out First Name box!</div>";
}
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strpos($url, 'error=last') !== false) {
echo "<div class='transition' style='height: 20px; background-color: #ff6b66; text-align: center; margin-top: 30px; margin-right: 40%; margin-left: 40%; border-radius: 20px; padding: 5px;'>Fill out Last Name box!</div>";
}
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strpos($url, 'error=email') !== false) {
echo "<div class='transition' style=' transition-delay: 1s;box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); height: 20px; background-color: #ff6b66; text-align: center; margin-top: 30px; margin-right: 40%; margin-left: 40%; border-radius: 20px; padding: 5px;'>Fill out Email box!</div>";
}
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strpos($url, 'error=user_name_taken') !== false) {
echo "<div class='transition' style='height: 20px; background-color: #ff6b66; text-align: center; margin-top: 30px; margin-right: 40%; margin-left: 40%; border-radius: 20px; padding: 5px;'>This username is already in use!</div>";
}
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strpos($url, 'error=user_email_taken') !== false) {
echo "<div class='transition' style='height: 20px; background-color: #ff6b66; text-align: center; margin-top: 30px; margin-right: 40%; margin-left: 40%; border-radius: 20px; padding: 5px;'>This email is already in use!</div>";
}
if (isset($_SESSION['id']) !== true) {
header('Location: ../login.php');
}
?>
<html>
<head>
<title>Add Teacher</title>
<link rel="stylesheet" type="text/css" href="../assets/css/adduser.css">
</head>
<body>
<div class="loginbox">
<h1 class="longintitle" style="font-family: Tahoma;">Add Teacher</h1>
<form class="form" action="../includes/adduser.php" method="post" enctype="multipart/form-data">
<input autocomplete="off" placeholder="Username" name="username" type="text" >
<input autocomplete="off" placeholder="Password" name="password" type="password">
<input autocomplete="off" placeholder="First Name" name="first" type="text">
<input autocomplete="off" placeholder="Last Name" name="last" type="text">
<input autocomplete="off" placeholder="Email" name="email" type="email">
<input class="loginbutton" name="create" type="submit" value="Create">
</form>
<p>Students will be in beta copie THIS IS ALPHA</p>
</div>
</body>
</html>
php for it
<?php
session_start();
include_once("../includes/db.php");
$id = $_POST['id'];
$username = $_POST['username'];
$password = $_POST['password'];
$first = $_POST['first'];
$last = $_POST['last'];
$email = $_POST['email'];
if (empty($username)) {
header('Location: ../teacher/adduser.php?error=username');
exit();
}
if (empty($password)) {
header('Location: ../teacher/adduser.php?error=password');
exit();
}
if (empty($first)) {
header('Location: ../teacher/adduser.php?error=first');
exit();
}
if (empty($last)) {
header('Location: ../teacher/adduser.php?error=last');
exit();
}
if (empty($email)) {
header('Location: ../teacher/adduser.php?error=email');
exit();
} else {
$sql = "SELECT * FROM user WHERE username='".$username."'";
$result = mysqli_query($conn, $sql);
$usernamecheck = mysql_num_rows($result);
if ($usernamecheck > 0) {
header('Location: ../teacher/adduser.php?error=user_name_taken');
exit();
}
$sql = "SELECT * FROM user WHERE email='$email'";
$result = mysqli_query($conn, $sql);
$emailtaken = mysql_num_rows($result);
if ($emailtaken > 0) {
header('Location: ../teacher/adduser.php?error=user_email_taken');
exit();
} else {
$sql = "INSERT INTO user (id, username, password, first, last, email) VALUES ('$id', '$username', '$password', '$first', '$last', '$email')";
$result = mysqli_query($conn, $sql);
header('Location: ../teacher/adduser.php');
}
}
?>
If need but "doubt it tho" the db.php
<?php
$conn = mysqli_connect("localhost", "dbuser", "dbpass", "dbmain");
if (!#mysqli_connect("localhost", "dbuser", "dbpass", "dbmain")) {
echo "<div style=' box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); padding: 3px; background-color: red; height: 20px;'><h3 style='text-align: center;'>Cannot connect to database have the admin take a look!</h3></div>";
die(mysql_error());
}
else {
echo "<div style=' box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); padding: 3px; background-color: lightgreen; height: 20px;'><h3 style='text-align: center;'>Connected to database Successfully!</h3></div>";
}
?>
Please help I dont know how to fix this! If you need more info just ask.
Thanks in advance!
As you are using mysqli, I think you may need to replace mysql_num_rows with mysqli_num_rows. (missing 'i' in mysqli_num_rows).
Replace "mysql_num_rows" with "mysqli_num_rows" , while fetching the rows. As $conn is a "mysqli_connect " instance.
Related
I have a problem. I created this code that shows products from my database like products:
<?php
include("connect.php");
session_start();
$status="";
if (isset($_POST['id']) && $_POST['id']!="")
{
$Id = $_POST['id'];
$result = mysqli_query($conn,"SELECT * FROM Producten WHERE `Id`='$Id'");
$row = mysqli_fetch_assoc($result);
$naam = $row['Naam'];
$id = $row['Id'];
$prijs = $row['Prijs'];
$foto = $row['Foto'];
$winkelwagen_array = array(
$id=>array(
'id'=>$id,
'naam'=>$naam,
'prijs'=>$prijs,
'hoeveelheid'=>1,
'foto'=>$foto)
);
if(empty($_SESSION["winkelwagen"]))
{
$_SESSION["winkelwagen"] = $winkelwagen_array;
$status = "<div class='box'>Product toegevoegd aan winkelwagen!</div>";
}
else
{
$_SESSION["winkelwagen"] = array_merge($_SESSION["winkelwagen"],$winkelwagen_array);
$status = "<div class='box'>Product toegevoegd aan winkelwagen!</div>";
}
}
?>
<html>
<head>
<link rel='stylesheet' href='css/style.css' type='text/css' media='all' />
</head>
<body>
<div style="width:700px; margin:50 auto;">
<?php
if(!empty($_SESSION["winkelwagen"]))
{
$winkelwagen_hoeveelheid = count(array_keys($_SESSION["winkelwagen"]));
?>
<div class="winkelwagen_div">
<img src="media/winkelwagen_logo.png" /> Winkelwagen<span><?php echo $winkelwagen_hoeveelheid; ?></span>
</div>
<?php
}
$result = mysqli_query($conn,"SELECT * FROM Producten");
while($row = mysqli_fetch_assoc($result))
{
echo "<div class='product_vak'>
<form method='post' actie=''>
<input type='hidden' name='id' value=".$row['Id']." />
<div class='foto'><img src='".$row['Foto']."' /></div>
<div class='naam'>".$row['Naam']."</div>
<div class='prijs'>€".$row['Prijs']."</div>
<button type='submit' class='koop'>Koop nu</button>
</form>
</div>";
}
mysqli_close($conn);
?>
<div style="clear:both;"></div>
<div class="melding_box" style="margin:10px 0px;">
<?php echo $status; ?>
</div>
</div>
</body>
</html>
with this css:
.product_vak {
float:left;
padding: 10px;
text-align: center;
}
.product_vak:hover {
box-shadow: 0 0 0 2px #e5e5e5;
cursor:pointer;
}
.product_vak .naam {
font-weight:bold;
}
.product_vak .koop {
text-transform: uppercase;
background: #F68B1E;
border: 1px solid #F68B1E;
cursor: pointer;
color: #fff;
padding: 8px 40px;
margin-top: 10px;
}
.product_vak .koop:hover {
background: #f17e0a;
border-color: #f17e0a;
}
.melding_box .box{
margin: 10px 0px;
border: 1px solid #2b772e;
text-align: center;
font-weight: bold;
color: #2b772e;
}
.table td {
border-bottom: #F0F0F0 1px solid;
padding: 10px;
}
.winkelwagen_div {
float:right;
font-weight:bold;
position:relative;
}
.winkelwagen_div a {
color:#000;
}
.winkelwagen_div span {
font-size: 12px;
line-height: 14px;
background: #F68B1E;
padding: 2px;
border: 2px solid #fff;
border-radius: 50%;
position: absolute;
top: -1px;
left: 13px;
color: #fff;
width: 14px;
height: 13px;
text-align: center;
}
.winkelwagen .verwijderen {
background: none;
border: none;
color: #0067ab;
cursor: pointer;
padding: 0px;
}
.winkelwagen .verwijderen:hover {
text-decoration:underline;
}
But when I load the page I see 2 products above each other in a very very large size. Now how can I get them to load next to each other and in a smaller size, because now they are filling the whole screen per product!
I already tried giving product_vak a width, but the image doesn't size with that!
How can I fix this?
try like this
.product_vak {
float:left;
padding: 10px;
text-align: center;
width:40%;
I have a comment system with a reply system and whenever I make a reply to a comment, it appears at the bottom, I must provide all of the code as I am not sure which piece of code is the problem.
I have add this problem for a while, I'm struggling with this problem, and I thank you for helping!
Here is my code for comments.inc.php:
<?php
function setComments($conn) {
if (isset($_POST['commentSubmit'])) {
$uid = $_POST['uid'];
$date = $_POST['date'];
$message = $_POST['message'];
$message = preg_replace (
"/(?<!a href=\")(?<!src=\")((http|ftp)+(s)?:\/\/[^<>\s]+)/i",
"\\0",
$message
);
$sql = "INSERT INTO comments (uid, date, message) VALUES ('".mysqli_real_escape_string($conn,$uid)."','".mysqli_real_escape_string($conn,$date)."','".mysqli_real_escape_string($conn,$message)."')";
$result = $conn->query($sql);
}
}
function getComments($conn) {
$sql = "SELECT * FROM comments";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$id = $row['uid'];
$sql2 = "SELECT * FROM users WHERE id='$id'";
$result2 = $conn->query($sql2);
if ($row2 = $result2->fetch_assoc()) {
echo "<div class='comment-box'><p>";
echo $row2['first_name']."<br>";
echo $row['date']."<br>";
echo nl2br($row['message']);
echo "</p>";
if (isset($_SESSION['id'])) {
if ($_SESSION['id'] == $row2['id']) {
echo "<form class='delete-form' method='POST' action='".deleteComments($conn)."'>
<input type='hidden' name='cid' value='".$row['cid']."'>
<button type='submit' name='commentDelete'>Delete</button>
</form>
<form class='edit-form' method='POST' action='editcomment.php'>
<input type='hidden' name='cid' value='".$row['cid']."'>
<input type='hidden' name='uid' value='".$row['uid']."'>
<input type='hidden' name='date' value='".$row['date']."'>
<input type='hidden' name='message' value='".$row['message']."'>
<button>Edit</button>
</form>
";
} else {
echo "<form class='edit-form' method='POST' action='replycomment.php'>
<input type='hidden' name='cid' value='".$row['cid']."'>
<input type='hidden' name='uid' value='".$row['uid']."'>
<input type='hidden' name='date' value='".$row['date']."'>
<input type='hidden' name='reply' value='".$row['reply']."'>
<button style='height: 90px;'><img src='img.ico' style=''></button>
</form>";
}
} else {
echo "<p class='commentmessage'>You need to be logged in to reply</p>";
}
echo "</div>";
}
}
}
function replyComments($conn) {
if (isset($_POST['replySubmit'])) {
$cid = $_POST['cid'];
$uid = $_POST['uid'];
$date = $_POST['date'];
$reply = $_POST['reply'];
$first_name = $_POST['first_name'];
$reply = preg_replace (
"/(?<!a href=\")(?<!src=\")((http|ftp)+(s)?:\/\/[^<>\s]+)/i",
"\\0",
$reply
);
$sql = "INSERT INTO replies (uid, first_name, date, reply) VALUES ('".mysqli_real_escape_string($conn,$uid)."','".mysqli_real_escape_string($conn,$first_name)."','".mysqli_real_escape_string($conn,$date)."','".mysqli_real_escape_string($conn,$reply)."')";
$result = $conn->query($sql);
header("Location: index1.php");
}
}
function deleteComments($conn) {
if (isset($_POST['commentDelete'])) {
$cid = $_POST['cid'];
$sql = "DELETE FROM comments WHERE cid='".mysqli_real_escape_string($conn,$cid)."'";
$result = $conn->query($sql);
header("Location: index1.php");
}
}
function editComments($conn) {
if (isset($_POST['commentSubmit'])) {
$cid = mysqli_real_escape_string($conn, $_POST['cid']);
$uid = mysqli_real_escape_string($conn, $_POST['uid']);
$date = mysqli_real_escape_string($conn, $_POST['date']);
$message = mysqli_real_escape_string($conn, $_POST['message']);
$sql = "UPDATE comments SET message='".mysqli_real_escape_string($conn,$message)."' WHERE cid='".mysqli_real_escape_string($conn,$cid)."'";
$result = $conn->query($sql);
header("Location: index1.php");
}
}
function getLogin($conn) {
if (isset($_POST['loginSubmit'])) {
$email = $_POST['email'];
$password = md5($_POST['password']);
$sql = "SELECT * FROM users WHERE email='$email' AND password='$password'";
$result = $conn->query($sql);
if (mysqli_num_rows($result) > 0) {
if($row = $result->fetch_assoc()) {
$_SESSION['id'] = $row['id'];
header("Location: index1.php?loginsuccess");
exit();
}
} else {
header("Location: index.php?loginfailed");
exit();
}
}
}
?>
replycomment.php:
<?php
date_default_timezone_set('America/New_York');
include 'dbh.inc.php';
include 'comments.inc.php';
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Comments</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php
$cid = $_POST['cid'];
$uid = $_POST['uid'];
$date = $_POST['date'];
$reply = $_POST['reply'];
$first_name = $_POST['first_name'];
echo "<form method='POST' action='".replyComments($conn)."'>
<input type='text' name='first_name' placeholder='First Name' value='".$first_name."'>
<br>
<input type='hidden' name='cid' value='".$cid."'>
<input type='hidden' name='uid' value='".$uid."'>
<input type='hidden' name='date' value='".$date."'>
<textarea name='reply'></textarea><br>
<button type='submit' name='replySubmit'>Reply</button>
</form>";
?>
</body>
</html>
index1.php:
<?php
date_default_timezone_set('America/New_York');
include 'dbh.inc.php';
include 'comments.inc.php';
session_start();
$statusMsg = $errorMsg = $insertValuesSQL = $errorUpload = $errorUploadType = '';
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Comments</title>
</head>
<style>
textarea {
width: 400px;
height: 80px;
background-color: #fff;
resize: none;
margin-left: 2%;
padding: 12px;
font-family: 'Lato', sans-serif;
}
button {
width: 100px;
height: 30px;
background-color: green;
border: none;
color: #fff;
font-weight: 400;
cursor: pointer;
margin-bottom: 60px;
margin-left: %;
font-family: 'Lato', sans-serif;
}
button:hover {
background-color: #282828;
}
.likebtn-wrapper {
margin-bottom: 550%;
}
.comment-box {
width: 845px;
padding: 15px;
margin-bottom: 1%;
background-color: #fff;
border-radius: 4px;
position: relative;
font-family: 'Lato', sans-serif;
}
.comment-box p {
font-size: 16px;
line-height: 20px;
color: gray;
font-weight: 100;
font-family: 'Lato', sans-serif;
padding: 2px 2px;
}
.edit-form {
position: absolute;
top: 0px;
right: 0px;
}
.edit-form button{
width: 40px;
height: 20px;
color: #282828;
background-color: #fff;
opacity: 0.7;
}
.edit-form button:hover{
opacity: 1;
}
.delete-form {
position: absolute;
top: 0px;
right: 60px;
}
.delete-form button{
width: 40px;
height: 20px;
color: #282828;
background-color: #fff;
opacity: 0.7;
}
.delete-form button:hover{
opacity: 1;
}
.reply-form {
float: left;
top: 0px;
right: 120px;
}
.reply-form button{
width: 40px;
height: 20px;
color: #282828;
background-color: #fff;
opacity: 0.7;
}
.reply-form button:hover{
opacity: 1;
}
.commentmessage {
float: right;
position: absolute;
top: 10px;
right: 10px;
font-size: 20px;
}
#myDIV {
width: 100%;
padding: 50px 0;
text-align: center;
background-color: lightblue;
margin-top: 20px;
display: none;
}
html {
margin: 0;
padding: 0;
background-color: #4ebd46;
font-family: 'Montserrat', sans-serif;
}
body {
width: 70%;
margin: 0 auto;
padding: 1em 50px;
background: #feffa6;
font-family: 'Montserrat', sans-serif;
}
.header {
background-color: #87ea6b;
margin: 0;
padding-top: 6%;
padding-bottom: -5%;
margin-top: -2%;
margin-left: -5.2%;
margin-right: -5.2%;
font-family: 'Montserrat', sans-serif;
}
h1, h2 {
text-align: center;
color: white;
font-family: 'Lato', sans-serif;
}
h1 {
font-size: 45px;
margin-left: -18%;
font-family: 'Lato', sans-serif;
}
.logo {
width: 35%;
margin-top: -20%;
}
button {
background-color: #90bd62;
}
.first {
margin-left: 2%;
}
a {
cursor: pointer;
}
.edit-form button{
width: 40px;
height: 20px;
color: #282828;
opacity: 0.7;
margin-left: -60%;
margin-top: 40%;
}
a:hover {
text-decoration: underline;
}
.first {
color: #821510;
font-size: 17px;
}
.replyson {
color: red;
}
.edit-form {
color: red;
}
footer {
padding: 0px;
background-color: #a5dbff;
padding: 10px;
text-align: center;
color: white;
padding-bottom: -20%;
margin-bottom: -2%;
margin-left: -5.2%;
margin-right: -5.2%;
}
.ooter {
padding: 0px;
background-color: #a5dbff;
padding: 20px;
text-align: center;
color: white;
padding-bottom: -50%;
margin-bottom: -2%;
margin-left: 10%;
margin-right: 10%;
}
.term {
color: white;
}
</style>
</head>
<body>
<br>
<br>
<div class="gallery">
<?php
include_once 'lendex.php';
$query = $db->query("SELECT * FROM images ORDER BY id DESC");
if($query->num_rows > 0) {
while($row = $query->fetch_assoc()) {
$imageURL = 'uploads/'.$row['file_name'];
?>
<img src="<?php echo $imageURL; ?>" width='200' height='200' alt=""/>
<?php }
} else { ?>
<p>No image(s) found...</p>
<?php } ?>
</div>
</div>
<div class="first">
<?php
if (isset($_SESSION['id'])) {
echo " <form method='POST' action='".setComments($conn)."'>
<input type='hidden' name='uid' value='".$_SESSION['id']."'>
<input type='hidden' name='date' value='".date('Y-m-d H:i:s')."'>
<textarea name='message'></textarea><br>
<br>
<button type='submit' name='commentSubmit' style='height: 60px;'>Comment</button>
</form>";
} else {
echo "You need to be logged in to comment!
<br><br>";
}
getComments($conn);
?>
</div>
<?php
$sql = "SELECT * FROM replies;";
$result = mysqli_query($conn,$sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<div class='comment-box'><p>";
echo $row['first_name'];
echo "<br>";
echo $row['date'];
echo "<br>";
echo $row['reply'];
echo "</p>";
echo "</div>";
}
}
?>
</body>
</html>
If you do not anticipate too long threads (otherwise this method will eat your RAM) then you can fetch the comments as a linear list and build the whole hierarchical structure/order of comments in 1 pass - then you will recursively iterate this large array of arrays and your replies will be immediate children of your comments:
$query = 'SELECT id, parent_id, title, body, author, created FROM comments ORDER BY COALESCE(parent_id, 0), id';
$result = $pdo->query($query);
$comments = array();
$refs = array();
while($row = $result->fetch(PDO::FETCH_ASSOC))
{
$thisref = &$refs[$row['id']];
$thisref['title'] = $row['title'];
$thisref['body'] = $row['body'];
$thisref['author'] = $row['author'];
$thisref['created'] = $row['created'];
if($row['parent_id'] == 0) $comments[$row['id']] = &$thisref;
else $refs[$row['parent_id']]['children'] = &$thisref;
}
To better understand the method - take a look at the article "One pass parent-child array structure"
I've been working on a system that allows a user to insert data, which will pass into a MySql database using SQL querieshowever, I've noticed that every time the page is refreshed, empty data is inserted into the database. Connection, queries, PHP, HTML and every other code works. The redirection works as intended but I realise my system just needs a slight correction. Am I doing something wrong?
<?php
$con = mysqli_connect("localhost","root","","system");
$error = 0;
$errormessage = "";
if( isset($_POST['submit'])){
$name = $_POST['name'];
$email = $_GET['email'];
$password = $_POST['password'];
$password = hash('sha256' , $password);
}else{
$errormessage = $errormessage . "Please Fill all Fields";
$error++;
}
if($errors == 0){
$sql = "INSERT INTO User
(name, email, password)
VALUES
('$name','$email','$password')";
mysqli_query($con, $sql) or die (mysqli_error($con));
$errormessage = "Data Successfully Entered";
}
?>
<!DOCTYPE html>
<html>
<body>
<header>
<div style="background-color:black"><div style="text-align:center;"> <h1><style="color:Black;">Register</h1></div></div> </header>
<style>
input[type=text], select {
width: 50%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 5px solid magenta;
border: 5px solid magenta;
border-radius: 4px;
box-sizing: border-box;
align:center;
}
input[type=button] {
width: 50%;
background-color: #4CAF50;
color: white;
padding: 14px 40px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
align:center;
}
input[type=password], select {
width: 50%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 5px solid magenta;
border: 5px solid magenta;
border-radius: 4px;
box-sizing: border-box;
align:center;
}
input[type=email], select {
width: 50%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 5px solid magenta;
border: 5px solid magenta;
border-radius: 4px;
box-sizing: border-box;
align:center;
}
input[type=submit] {
width: 50%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
align:center;
}
input[type=submit]:hover {
background-color: green;
}
div {
margin-left:auto;
margin-right:auto;
width: 90%;
border: 5px solid lime;
border-radius: 5px;
background-color: #ECF0F1;
padding: 20px;
}
</style>
</nav>
<div>
<form method="Post">
<label for="name">
<div style="text-align:center;"><input type= "button" id="RegisterPage" value = "Go to Register Page" onclick="document.location.href='example.php'">
<input type= "button" id="LoginPage" value = "Go to Login Page" onclick="document.location.href='http://localhost/example2.php'"><p>Your Name</label><br>
<input type="text" id="name" name="name" placeholder="Enter Name" required><br>
<label for="email">E-Mail:</label><br>
<input type="email" id="email" name="email" placeholder="Your e-mail" required><br>
<label for="password">Password:</label><br>
<input type="password" name="password" placeholder="At least 6 characters" required><br>
<input type="submit" name = "submit" value="Create your Account ">
</form></div>
<footer><div style="background-color:aqua; border: 5px solid black;">
</form></div>
</footer>
</nav>
</body>
</html>
You can do a ON DUPLICATE KEY UPDATE with your insert statement to update the database records instead of entering more. Also, make sure to setup your primary keys in your DB.
$sql = "INSERT INTO User
(name, email, password)
VALUES
('$name','$email','$password')
ON DUPLICATE KEY UPDATE
name = `$name`, email = `$email`, `$password`";
I'm trying to align the items in the center of the page. I'm using display: flex however, this causes the text to be split up into different columns but I don't want that, I want the text to be normal, you know. When the session is set, the text will show; you can see the forms are aligned in the center, but the text isn't.
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
letter-spacing: -0.5px;
}
html,
body {
height: 100%;
width: 100%;
background: #fff;
}
.content-container {
width: 100%;
height: auto;
padding: 10pt;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0 auto;
margin-top: 30pt;
display: flex;
justify-content: center;
}
.header {
top: 0;
position: fixed;
height: 30pt;
width: 100%;
background: rgba(255, 255, 255, 0.50);
border-bottom: 1.5px solid #0047FF;
}
.header-content {
width: 100%;
height: inherit;
margin: 0 auto;
white-space: nowrap;
line-height: 30pt;
padding: 0 5pt;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.header-menu {
border-right: 1px solid #0047FF;
margin-right: 10pt;
width: auto;
height: inherit;
float: left;
padding: 0 5pt 0 0;
}
.header-menu ul li {
list-style: none;
float: left;
}
.header-menu ul li a {
color: #555;
text-decoration: none;
padding: 0 3pt;
float: left;
}
.logout-form__ button {
background: none;
cursor: pointer;
border: none;
outline: none;
color: #555;
}
.logout-form__ button:hover {
color: #888
}
.header-menu ul li a:after {
content: "/";
padding: 0 0 0 5pt
}
.header-menu ul li:last-child a:after {
content: "";
padding: 0;
}
.header-menu ul li a:hover {
color: #888;
}
.header-menu ul li a:hover:after {
color: #555
}
.header-search form input {
border: none;
background: rgba(255, 255, 255, 0.50);
outline: none;
padding: 5pt;
border-top: 1px solid #eee;
width: 250pt;
display: inline-block;
color: #555
}
.header-search form input:focus {
border-color: #ccc;
background: rgba(255, 255, 255, 0.80)
}
.header-search form button {
background: rgba(255, 255, 255, 0.50);
border: none;
outline: none;
border-top: 1px solid #eee;
padding: 5pt;
cursor: pointer;
color: #555
}
.header-search form button:hover {
border-color: #ccc;
background: rgba(255, 255, 255, 0.60);
}
.same-form-styling {
float: left;
padding: 10pt 0;
border-bottom: 1px solid #ccc;
width: auto;
width: 400pt
}
.forms-title {
border-bottom: 1px solid #ccc;
padding: 0 0 10pt 0;
margin-bottom: 10pt
}
.forms-title span {
font-size: 16px;
}
.same-form-styling form input {
width: 100%;
display: block;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10pt 0;
border: none;
outline: none;
border-bottom: 1px solid #eee;
}
.same-form-styling form button {
border: none;
outline: none;
padding: 10pt;
border-left: 1px solid #eee;
float: left;
background: none;
border-right: 1px solid #eee;
width: 150pt;
}
<?php
include_once './Private/Backend/Database/conn.php';
if(isset($_POST['logout'])) {
session_destroy();
unset($_SESSION['id']);
unset($_SESSION['username']);
unset($_SESSION['email']);
header("location: index.php?a=login");
}
/* ### */
if(isset($_POST['login-btn'])) {
$l_email = mysqli_real_escape_string($main, $_POST['l-email']);
$l_email = stripcslashes($l_email);
$l_pass = mysqli_real_escape_string($main, $_POST['l-pass']);
$l_pass = stripcslashes($l_pass);
if(filter_var($l_email, FILTER_VALIDATE_EMAIL)) {
$hashed = md5(sha1(md5(sha1($l_pass))));
$sql = "SELECT * FROM accounts WHERE email='$l_email' and password='$hashed'";
$result = mysqli_query($main, $sql);
if(mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$_SESSION['id'] = $row['id'];
$_SESSION['username'] = $row['username'];
$_SESSION['email'] = $row['email'];
header("location: index.php");
}
} else {
header("location: index.php?a=login&loginErr=wrong&email=$l_email");
}
} else {
header("location: index.php?a=login&loginErr=invalidEmail&email=$l_email");
}
}
if(isset($_POST['reg-btn'])) {
$username = mysqli_real_escape_string($main, $_POST['reg-uname']);
$username = stripcslashes($username);
$username = strip_tags($username);
$email = mysqli_real_escape_string($main, $_POST['reg-email']);
$email = stripcslashes($email);
$email = strip_tags($email);
$email_c = mysqli_real_escape_string($main, $_POST['reg-c-email']);
$email_c = stripcslashes($email_c);
$pass = mysqli_real_escape_string($main, $_POST['reg-pass']);
$pass = stripcslashes($pass);
$pass_c = mysqli_real_escape_string($main, $_POST['reg-c-pass']);
$pass_c = stripcslashes($pass_c);
if(!empty($username && $email && $email_c && $pass && $pass_c)) {
$sql = "SELECT * FROM accounts WHERE username='$username'";
$result = mysqli_query($main, $sql);
if(mysqli_num_rows($result) > 0 ){
header("location: index.php?a=register®isterErr=userTaken&username=$username&email=$email&cEmail=$email_c");
} else {
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
if($email == $email_c) {
$sql = "SELECT * FROM accounts WHERE email='$email'";
$result = mysqli_query($main, $sql);
if(mysqli_num_rows($result) > 0) {
header("location: index.php?a=register®isterErr=emailTaken&username=$username&email=$email&cEmail=$email_c");
} else {
if(strlen($pass) >= 6) {
if($pass == $pass_c) {
$hashedBrown = md5(sha1(md5(sha1($pass))));
$sql = "INSERT INTO accounts (username, account_type, first_name, last_name, gender, bio, email, password) VALUES ('$username', 'Regular User' , '', '', '', '','$email', '$hashedBrown')";
$result = mysqli_query($main, $sql);
$sql = "SELECT * FROM accounts WHERE username='$username' and email='$email'";
$result = mysqli_query($main, $sql);
$row = mysqli_fetch_assoc($result);
$_SESSION['id'] = $row['id'];
$_SESSION['username'] = $row['username'];
$_SESSION['email'] = $row['email'];
header("location: index.php");
} else {
header("location: index.php?a=register®isterErr=passwordsDoNotMatch&username=$username&email=$email&cEmail=$email_c");
}
} else {
header("location: index.php?a=register®isterErr=passwordLen&username=$username&email=$email&cEmail=$email_c");
}
}
} else {
header("location: index.php?a=register®isterErr=emailsDoNotMatch&username=$username&email=$email&cEmail=$email_c");
}
} else {
header("location: index.php?a=register®isterErr=username=$username&email=$email&cEmail=$email_c");
}
}
} else {
header("location: index.php?a=register®isterErr=allEmpty");
}
}
?>
<!DOCTYPE html>
<html lang="en" style="overflow-x: hidden;">
<head>
<meta charset="UTF-8" />
<title>ICode Foundation</title>
<link rel="stylesheet" type="text/css" href="./Public/CSS/Beta/all.css" />
</head>
<body>
<div class="header">
<div class="header-content">
<div class="header-menu">
<ul>
<?php if(!isset($_SESSION['id'])) { ?><li>Register</li><?php } ?>
<?php if(!isset($_SESSION['id'])) { ?><li>Login</li><?php } ?>
<?php if(isset($_SESSION['id'])) { ?><li>Home</li><?php } ?>
<?php if(isset($_SESSION['id'])) { ?><li>You <span>(<strong><?php echo $_SESSION['username']; ?></strong>)</span></li><?php } ?>
<?php if(isset($_SESSION['id'])) { ?><li><a href="#">
<form action="index.php" method="POST" class="logout-form__">
<button type="submit" name="logout">
Logout
</button>
</form>
</a></li><?php } ?>
</ul>
</div>
<div class="header-search">
<form action="#" method="GET">
<input type="text" placeholder="Search" name="q" autocomplete="off" /><button type="submit" name="search-btn">Search</button>
</form>
</div>
</div>
</div>
<div class="content-container">
<?php if(!isset($_SESSION['id'])) { ?>
<?php if(isset($_GET['a'])) { ?>
<?php if($_GET['a']=="register") { ?>
<div class="register same-form-styling">
<div class="forms-title"><span>Register</span></div>
<form action="index.php" method="POST">
<input type="text" name="reg-uname" placeholder="Username" <?php if(isset($_GET['username'])) { echo 'value="' . $_GET['username'] . '"'; } ?> />
<input type="text" name="reg-email" placeholder="Email Address" <?php if(isset($_GET['email'])) { echo 'value="' . $_GET['email'] . '"'; } ?> />
<input type="text" name="reg-c-email" placeholder="Confirm Email" <?php if(isset($_GET['cEmail'])) { echo 'value="' . $_GET['cEmail'] . '"'; } ?> />
<input type="password" name="reg-pass" placeholder="Password" />
<input type="password" name="reg-c-pass" placeholder="Confirm Password" />
<button type="submit" name="reg-btn">Register</button>
</form>
<div class="register-info" style="clear:both;border-top: 1px solid #ccc;padding: 10pt 0 0 0;">You are not hindered to a specific array of characters to inlude in your password therefore, ensure your password is strong and memorable. Hindering users on what characters they can use in their password is an idiotic move hence, we don't include such feature nor endorse this practice. It is solely your fault and responsibility if your password is easily guessable.</div>
</div>
<?php } elseif($_GET['a']=="login") { ?>
<div class="login same-form-styling">
<div class="forms-title"><span>Login</span></div>
<form action="index.php" method="POST">
<input type="text" placeholder="Email" name="l-email" <?php if(isset($_GET['email'])) { echo 'value="' . $_GET['email'] . '"'; } ?> />
<input type="password" placeholder="Password" name="l-pass" />
<button type="text" name="login-btn">Login</button>
</form>
</div>
<?php } else { ?>
<div class="unknown">
Unknown operation; it's either login or register.
</div>
<?php } ?>
<?php } ?>
<?php } else { ?>
<h1>Welcome</h1>
<p>All you can do is log in, edit your profile can search, view other profiles. Functionality such as blogging is an intended feature to soon be implemented. This site will go through major updates to ensure full reliability and user usability. Other major implementations such as code integrations to advance the site's functionality is desirable however, this site shouldn't be too advanced which could lead to hindrances thinking of new concepts for future updates.</p>
<p>This site will be powered by volunteers; voluntary developers, graphic designers and other skills that are beneficially suggestive towards this project. Your skills must include an array of professional and impeccable knowledge of a broad range of subjects and that bring in a diverse array of talent of knowledge to this project to grow and enlarge the project in many different ways. If you're interested in developing the site, email the lead developer at adamhope470#gmail.com. </p>
<p>You must lay your email out in a way that is comprehensible and professional. Ensure that you include your skills and how you will benefit the project in an innovative and intuitive manner. Include your programming skills and what programming languages do you know etc. Any other things that may help the project in different ways.</p>
<p>Skills like legal and business is helpful alongside impeccable English language skills. These skills will eventually contribute to administration and communicating with users to provide support wherever mandatory. You account role will fluctuate the features that you have access to; do not ask nor request roles of high rank, trusted members will be granted administration whereas moderators will be nominated based on the contributions they have made like translations etc. This is a for-profit project however, this will be a non-profitable project for the time being. </p>
<p>If you have any inquiries, questions or reports, you can contact the site's lead developer here or you can contact another administrator here.</p>
<p><strong>Your account could be susceptible to a susepnsion or a perminate ban if you're ever witnessed infringing our community guidelines. Review them here. These guidelines will ensure that the tranquility is persistant throughput, which will ensure that this service is safe for everyone to use. With that stated, before pursuing, you agree that you're 13 years or older.</strong></p>
<?php } ?>
</div>
<div class="footer-wrap">
</div>
</body>
</html>
When you set display: flex on an element it automatically applies flex-direction: row and flex-wrap: nowrap on the children (flex items).
This means that the items will line up horizontally and cannot wrap.
You have this:
.content-container {
display: flex;
justify-content: center;
}
jsfiddle demo
Instead, set the container to a vertical direction and then center the items:
.content-container {
display: flex;
flex-direction: column;
align-items: center;
}
jsfiddle demo
i can not get my Login script to login... i have an index.php with a register form and a login form, the register form works perfectly, but it seems like the login form does not get the information from the database when you enter the "login" button, when logging in you is redirectet to "home.php" which wil show your username with help of sessions. but i get this error "Notice: Undefined variable: username in home.php on line 12"... I think its because its not logging in and the session gets an undefined variabel. I just cant find where the problem is
i have a database named "thesozializer"
and the sql for the table is:
CREATE TABLE IF NOT EXISTS users (
id int(11) NOT NULL,
username varchar(255) NOT NULL,
first_name varchar(255) NOT NULL,
last_name varchar(255) NOT NULL,
email varchar(255) NOT NULL,
password varchar(32) NOT NULL,
sign_up_date date NOT NULL,
activated enum('0','1') NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;
index.php looks like this:
<?php
mysql_connect("localhost","root","") or die("couldn't connect to database.");
mysql_select_db("thesocializer") or die("couldn't select database");
$reg = #$_POST['reg'];
//declaring variables to prevent errors
$fn = ""; //First Name
$ln = ""; //Last Name
$un = ""; //Username
$em = ""; //Email
$em2 = ""; //Email 2
$pswd = ""; //Password
$pswd2 = ""; // Password 2
$d = ""; // Sign up Date
$u_check = ""; // Check if username exists
//registration form
$fn = strip_tags(#$_POST['fname']);
$ln = strip_tags(#$_POST['lname']);
$un = strip_tags(#$_POST['username']);
$em = strip_tags(#$_POST['email']);
$em2 = strip_tags(#$_POST['email2']);
$pswd = strip_tags(#$_POST['password']);
$pswd2 = strip_tags(#$_POST['password2']);
$d = date("Y-m-d"); // Year - month - day
if ($reg) {
if ($em==$em2) {
// Check if user already exists
$u_check = mysql_query("SELECT username FROM users WHERE username='$un'");
// Count the amount of rows where username = $un
$check = mysql_num_rows($u_check);
//Check whether Email already exists in the database
$e_check = mysql_query("SELECT email FROM users WHERE email='$em'");
//Count the number of rows returned
$email_check = mysql_num_rows($e_check);
if ($check == 0) {
if ($email_check == 0) {
//check all of the fields have been filed in
if ($fn&&$ln&&$un&&$em&&$em2&&$pswd&&$pswd2) {
// check that passwords match
if ($pswd==$pswd2) {
// check the maximum length of username/first name/last name does not exceed 25 characters
if (strlen($un)>25||strlen($fn)>25||strlen($ln)>25) {
echo "maximum length of username/first name/last name is 25 characters!";
}
else
{
// check the maximum length of password does not exceed 25 characters and is not less than 5 characters
if (strlen($pswd)>30||strlen($pswd)<5) {
echo "Password must be between 5 and 25 characters!";
}
else
{
//encrypt password and password 2 using md5 before sending to database
$pswd = md5($pswd);
$pswd2 = md5($pswd2);
$query = mysql_query("INSERT INTO users VALUES ('','$un','$fn','$ln','$em','$pswd','$d','0')");
die("<h2>welcome to The Socializer!</h2>Login to get started");
}
}
}
else {
echo "your passwords is incorrect";
}
}
else
{
echo "fill in all fields";
}
}
else
{
echo "email already in use";
}
}
else
{
echo "username already in use";
}
}
else {
echo "The emails is not alike!";
}
}
//User Login Code
if (isset($_POST["user_login"]) && isset($_POST["password_login"])) {
$user_login = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["user_login"]);
$password_login = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["password_login"]);
$password_login_md5 = md5($password_login);
$sql = mysql_query("SELECT id FROM users WHERE username='$user_login' AND password='$password_login_md5' LIMIT 1");
//Check for their existance
$userCount = mysql_num_rows($sql); //Count the number of rows returned
if ($userCount == 1) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
}
$_SESSION["user_login"] = $user_login;
header("location: home.php");
exit();
}
else {
echo 'username or password is incorrect';
exit();
}
}
session_start();
if (!isset($_SESSION["user_login"])) {
}
else
{
$username = $_SESSION["user_login"];
}
?>
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#registrer-deg").click(function(){
$("#registrerdeg").show();
});
$("#registrer-deg").click(function(){
$("#logginn").hide();
});
$("#logg-inn").click(function(){
$("#logginn").show();
});
$("#logg-inn").click(function(){
$("#registrerdeg").hide();
});
});
</script>
<link rel="stylesheet" type="text/css" href="main.css"/>
<title>The Socializer</title>
</head>
<body>
<div id="sidebarLeft">
<div id="logo"></div>
<ul>
<li>Login</li>
<li>Register</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
<div id="timeline">
<div id="registrering">
<form id="registrerdeg" action="index.php" method="POST" style="display: none;">
<input type="text" name="fname" size="10" placeholder="First name"><br/>
<input type="text" name="lname" size="10" placeholder="Last name"><br/>
<input type="text" name="username" size="10" placeholder="Username"><br/>
<input type="text" name="email" size="10" placeholder="Email"><br/>
<input type="text" name="email2" size="10" placeholder="Confirm email"><br/>
<input type="text" name="password" size="10" placeholder="Password"><br/>
<input type="text" name="password2" size="10" placeholder="Confirm Password"><br/>
<input type="submit" name="reg" value="Registrer!">
</form>
</div>
<div id="logg_inn">
<form id="logginn" action="index.php" method="POST" style="display: none;">
<input type="text" name="user_login" size="10" placeholder="Username"><br/>
<input type="text" name="password_login" size="10" placeholder="Password"><br/>
<input type="submit" name="login" value="Logg inn!">
</form>
</div>
</div>
</body>
</html>
* {
background-color: #2C3E50;
font-family: Arial, Helvetica, Sans-serif;
font-size: 16px;
color: #AFEEEE;
}
#sidebarLeft {
width: 220px;
height: 550px;
top: 0;
left: 0;
margin-top: 50px;
margin-left: 0px;
margin-bottom: 50px;
position: fixed;
}
#sidebarRight {
width: 220px;
height: 550px;
right: 0;
top: 0;
margin-top: 50px;
margin-right: 0px;
margin-bottom: 50px;
position: fixed;
}
ul {
width: 220px;
list-style-type: none;
margin: 0px;
padding: 0;
margin-top: 30px;
}
li {
height: 35px;
width: 220px;
list-style-type: none;
margin: 5px;
}
#logo {
width: 150px;
height: 150px;
background-image: url("../img/logo.png");
-moz-border-radius: 75px;
-webkit-border-radius: 750px;
border-radius: 75px;
margin-left: 35px;
margin-top: 25px;
}
#sidebarLeft ul li a {
display: block;
width: 60px;
width: 220px;
height: 16px;
text-align: center;
margin-top: 9px;
text-decoration: none;
color: #AFEEEE;
}
#timeline {
width: 780px;
height: 550px;
margin-top: 50px;
margin-left: 240px;
top: 0;
}
input[type="text"] {
background-color: #FFFFFF;
border: 1px solid #E2E2E2;
color: #000000;
font-size: 15px;
font-weight: bold;
padding: 5px;
width: 200px;
height: 12px;
margin-bottom: 3px;
margin-top: 3px;
outline: none;
}
::-webkit-input-placeholder {
font-weight: normal;
}
:-moz-input-placeholder {
font-weight: normal;
}
::-moz-input-placeholder {
font-weight: normal;
}
:-ms-input-placeholder {
font-weight: normal;
}
input[type="submit"] {
border-top: 1px solid #96d1f8;
background: #61a6d4;
background: -webkit-gradient(linear, left top, left bottom, from(#316c94), to(#61a6d4));
background: -webkit-linear-gradient(top, #316c94, #61a6d4);
background: -moz-linear-gradient(top, #316c94, #61a6d4);
background: -ms-linear-gradient(top, #316c94, #61a6d4);
background: -o-linear-gradient(top, #316c94, #61a6d4);
padding: 5px 10px;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
-webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;
-moz-box-shadow: rgba(0,0,0,1) 0 1px 0;
box-shadow: rgba(0,0,0,1) 0 1px 0;
text-shadow: rgba(0,0,0,.4) 0 1px 0;
color: #ffffff;
font-size: 12px;
font-family: Helvetica, Arial, Sans-Serif;
text-decoration: none;
vertical-align: middle;
}
input[type="submit"]:hover {
border-top-color: #49718c;
background: #49718c;
color: #ccc;
}
input[type="submit"]:active {
border-top-color: #1b435e;
background: #1b435e;
}
and home.php looks like this:
<?php
mysql_connect("localhost","root","") or die("couldn't connect to database.");
mysql_select_db("thesocializer") or die("couldn't select database");
session_start();
if (!isset($_SESSION["user_login"])) {
}
else
{
$username = $_SESSION["user_login"];
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/main.css"/>
<title>The Socializer</title>
</head>
<body>
<div id="sidebarLeft">
<div id="logo">
</div>
<ul>
<li>Logg inn</li>
<li>Registrer deg</li>
<li>Om</li>
<li>Kontakt</li>
</ul>
</div>
<div id="timeline">
<?php echo "Hello, ".$username; ?>
</div>
</body>
</html>
* {
background-color: #2C3E50;
font-family: Arial, Helvetica, Sans-serif;
font-size: 16px;
color: #AFEEEE;
}
#sidebarLeft {
width: 220px;
height: 550px;
top: 0;
left: 0;
margin-top: 50px;
margin-left: 0px;
margin-bottom: 50px;
position: fixed;
}
#sidebarRight {
width: 220px;
height: 550px;
right: 0;
top: 0;
margin-top: 50px;
margin-right: 0px;
margin-bottom: 50px;
position: fixed;
}
ul {
width: 220px;
list-style-type: none;
margin: 0px;
padding: 0;
margin-top: 30px;
}
li {
height: 35px;
width: 220px;
list-style-type: none;
margin: 5px;
}
#logo {
width: 150px;
height: 150px;
background-image: url("../img/logo.png");
-moz-border-radius: 75px;
-webkit-border-radius: 750px;
border-radius: 75px;
margin-left: 35px;
margin-top: 25px;
}
#sidebarLeft ul li a {
display: block;
width: 60px;
width: 220px;
height: 16px;
text-align: center;
margin-top: 9px;
text-decoration: none;
color: #AFEEEE;
}
#timeline {
width: 780px;
height: 550px;
margin-top: 50px;
margin-left: 240px;
top: 0;
}
input[type="text"] {
background-color: #FFFFFF;
border: 1px solid #E2E2E2;
color: #000000;
font-size: 15px;
font-weight: bold;
padding: 5px;
width: 200px;
height: 12px;
margin-bottom: 3px;
margin-top: 3px;
outline: none;
}
::-webkit-input-placeholder {
font-weight: normal;
}
:-moz-input-placeholder {
font-weight: normal;
}
::-moz-input-placeholder {
font-weight: normal;
}
:-ms-input-placeholder {
font-weight: normal;
}
input[type="submit"] {
border-top: 1px solid #96d1f8;
background: #61a6d4;
background: -webkit-gradient(linear, left top, left bottom, from(#316c94), to(#61a6d4));
background: -webkit-linear-gradient(top, #316c94, #61a6d4);
background: -moz-linear-gradient(top, #316c94, #61a6d4);
background: -ms-linear-gradient(top, #316c94, #61a6d4);
background: -o-linear-gradient(top, #316c94, #61a6d4);
padding: 5px 10px;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
-webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;
-moz-box-shadow: rgba(0,0,0,1) 0 1px 0;
box-shadow: rgba(0,0,0,1) 0 1px 0;
text-shadow: rgba(0,0,0,.4) 0 1px 0;
color: #ffffff;
font-size: 12px;
font-family: Helvetica, Arial, Sans-Serif;
text-decoration: none;
vertical-align: middle;
}
input[type="submit"]:hover {
border-top-color: #49718c;
background: #49718c;
color: #ccc;
}
input[type="submit"]:active {
border-top-color: #1b435e;
background: #1b435e;
}
you have to move the session_start();
in both pages at the begin of your script.
index.php:
<?php
session_start();
mysql_connect("localhost","root","") or die("couldn't connect to database.");
...
home.php:
<?php
session_start();
mysql_connect("localhost","root","") or die("couldn't connect to database.");
...