loading PHP on my HTML

Hello guys, how can I have my php load on the same page as my HTML page. for example, when the user clicks register and hasn’t filled all the boxes instead of saying “fill all boxes” on a new page. I want it load on the same HTML page.

<div class="submit"> <input type="submit" name='submit' value="Register" id="button-blue" /> <div class="ease"></div>

my php code:

[php]<?php
$submit = &$_POST[‘submit’];

//form data
$firstName = strip_tags(@$_POST[‘firstName’]);
$LastName = strip_tags(@$_POST[‘LastName’]);
$username = strip_tags(@$_POST[‘username’]);
$password = (strip_tags(@$_POST[‘password’]));
$repeatpassword = (strip_tags(@$_POST[‘repeatpassword’]));
$date = date(“Y-m-d”);

if ($submit)

{

//check for existance
if ($firstName&&$LastName&&$username&&$password&&$repeatpassword)

{

if ($password==$repeatpassword)
{

//chech char of user
if (strlen($username)>25||strlen($firstName)>25)
{
	echo "Length of username or fullname is too long!";
}
else
{

//check password length
if (strlen($password)>25||strlen($password)<6)
{

echo "Password must be between 6 and 25 charcters";

}
else
{	

//register the user!

//encrypt password
$password = md5($password);
$repeatpassword = md5($repeatpassword);

//open database
$connect = mysql_connect(“********”,”*****”,”*****”) or die ("couldn't connect!");
    mysql_select_db("ma301sl_FitnessPal1") or die("couldn't find db");

//generate random number for activation process

$queryreg = mysql_query("

INSERT INTO register VALUES(’’,’$firstName’,’$LastName’,’$username’,’$password’,’$date’)

");

die (“You have been registered! Return to main menu Return to login.”);

}
	
}

}
else
	echo "Your password do not much";

}

else
echo “Please fill in all fields!”;
}

?>[/php]

Thanks

I would like to help but, can’t. You need to find an updated tutorial/ book for this. What you are using is very outdated and will not help you in the long run, examples:

mysql_ is depreciated and is no longer supported. It has huge security vulnerabilities and should be abandoned in favor of either mysqi_ or PDO.

Hashing anything in MD5 is a huge red flag. There are far better such as sha256(), whirlpool, ect.

Post your actual form code. There are spots you can use to place error messages. JavaScript and JQuery should be the first thing you use to authenticate a form submission. PHP last, not because it is less important, the opposite actually. But, because you can use JavaScript to check with PHP to see if the values are okay to proceed.

Sponsor our Newsletter | Privacy Policy | Terms of Service