Answer the question
In order to leave comments, you need to log in
Why does html disappear when parsing php?
There is a registration window that appears when you click on one of the buttons in the navigation. I made the appearance through JQuery.
<div>
<div class="col-md-8" id="popreg">
<p>Registration</p> <!--RUNS-->
<?php include_once "register.php";
?>
<form method="post" action="logged.php"> <!--DOES NOT RUN-->
<p>
<input type="text" size="16" name="username" placeholder="username" required/>
</p>
<p>
<input type="text" size="16" name="email" placeholder="email" required/>
</p>
<p>
<input type="password" size="16" name="password" placeholder="password" required/>
</p>
<p>
<input type="password" size="16" name="check_password" placeholder="Repeat password" required/> <br>
</p>
<p id="signbutton">
<input type="submit" size="16" name="submit" value="Sign in"/>
</p>
</form>
</div>
</div>
<?php
# SQL CONNECTION
$connect = mysql_connect('localhost:8889', 'root', '12439524') or die(mysql_error());
mysql_select_db('pumprate');
# REGISTRATION CHECK
if (isset($_POST["submit"])) {
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];
$check_password = $_POST["check_password"];
# CHECKS PASSWORD AND IT'S CONFIRMATION
if ($password == $check_password) {
# WEAK CODE PROTECTION
$password = md5($password);
# CREATE A QUERY
$query = mysql_query("INSERT INTO users VALUES ("","$username","$password")") or die(mysql_error());
} else {
# PAGE THAT ERRORS WRONG PASSWORDS
die('Passwords must match!')
};
}
?>
Answer the question
In order to leave comments, you need to log in
<?php
# SQL CONNECTION
$connect = mysql_connect('localhost:8889', 'root', '12439524') or die(mysql_error());
mysql_select_db('pumprate');
# REGISTRATION CHECK
if (isset($_POST["submit"])) {
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];
$check_password = $_POST["check_password"];
# CHECKS PASSWORD AND IT'S CONFIRMATION
if ($password == $check_password) {
# WEAK CODE PROTECTION
$password = md5($password);
# CREATE A QUERY
$query = mysql_query("INSERT INTO users VALUES ('','$username','$password')") or die(mysql_error());
} else {
# PAGE THAT ERRORS WRONG PASSWORDS
die('Passwords must match!');
}
}
?>
die('Passwords must match!')
};
There are at least two errors.
In line 20, there is a confusion with quotes, it should be:
and in general esteem about PDO.
in line 25 there is no sign ";".
Check that you have error display enabled in PHP, view the source code of the fragment in which you are performing the include in the browser, there should be an error message indicating the problem.
How to write in PHP: www.phptherightway.com
Do not work directly with the base.
Rewrite the connection with at least mysqli .
Use Prepared Queries instead of directly passing variables to the sql query.
Write a function that will clean up garbage from variables .
Install an editor with a simple validator to avoid problems with the code.
Well, at the very end, you can close the connection to the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question