Register PhP code don't work

Hi, i created a register php code, and it don’t work can you help me ? the code :

//

<?php $servername = "localhost"; $username = "id11368693_zirvax"; $password = "**secrets**"; $database = "id11368693_espace_membre"; $bdd = new PDO("mysql:host=$servername;dbname=$database", $username, $password); if(isset($_POST['confirm_register'])) { if(isset($_POST['username']) AND isset($_POST['email']) AND isset($_POST['password']) AND isset($_POST['password_confirm'])) { if(!empty($_POST['username'])AND !empty($_POST['email']) AND !empty($_POST['password']) AND !empty($_POST['password_confirm'])) { $username = trim(htmlspecialchars($_POST['username'])); $email = trim(htmlspecialchars($_POST['email'])); $password = trim(htmlspecialchars($_POST['password'])); $password_confirm = trim(htmlspecialchars($_POST['password_confirm'])); if(strlen($email) <= 255) { if(filter_var($email, FILTER_VALIDATE_EMAIL)) { if(strlen($username) >= 3 AND strlen($username) <= 255) { if(strlen($password) >=6 AND strlen($password) <=100) { if($password == $password_confirm) { $password_crypted = sha1($password); $req = $bdd->prepare("INSERT INTO users (pseudo, email, password) VALUES (?,?,?)"); $req-execute(array($username, $email, $password_crypted)); $error = "Compte creer"; } else { $error = "Les deux mots de passes ne correspondent pas."; } } else { $error = "Le mot de passe doit contenir entre 6 et 100 caractères."; } } else { $error = "Le pseudonyme doit contenir entre 3 et 255 caractères."; } } else { $error = "Veuillez entrer une adresse e-mail valide."; } } else { $error = "Veuillez entrer une adresse e-mail valide."; } } else { $error = "Veuillez remplit tous les champs."; } } } ?>

//

URL is missing :frowning:

Hi, i created a register php code and, it don’t work… Can you help me ?
Link of the page: https://ici-cest-la-fete.000webhostapp.com/dev/register.php

Code :<?php

$servername = “localhost”;

$username = “id11368693_zirvax”;

$password = “secrets”;

$database = “id11368693_espace_membre”;

$bdd = new PDO(“mysql:host=$servername;dbname=$database”, $username, $password);

if(isset($_POST[‘confirm_register’])) {
if(isset($_POST[‘username’]) AND isset($_POST[‘email’]) AND isset($_POST[‘password’]) AND isset($_POST[‘password_confirm’])) {
if(!empty($_POST[‘username’])AND !empty($_POST[‘email’]) AND !empty($_POST[‘password’]) AND !empty($_POST[‘password_confirm’])) {

		$username = trim(htmlspecialchars($_POST['username']));
		$email = trim(htmlspecialchars($_POST['email']));
		$password = trim(htmlspecialchars($_POST['password']));
		$password_confirm = trim(htmlspecialchars($_POST['password_confirm']));

		if(strlen($email) <= 255) {
			if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
				if(strlen($username) >= 3 AND strlen($username) <= 255) {
					if(strlen($password) >=6 AND strlen($password) <=100) {
						if($password == $password_confirm) {
							
							$password_crypted = sha1($password);

							$req = $bdd->prepare("INSERT INTO users (pseudo, email, password) VALUES (?,?,?)");
							$req-execute(array($username, $email, $password_crypted));

							$error = "Compte creer";

						} else {
							$error = "Les deux mots de passes ne correspondent pas.";
						}
					} else {
						$error = "Le mot de passe doit contenir entre 6 et 100 caractères.";
					}
				} else {
					$error = "Le pseudonyme doit contenir entre 3 et 255 caractères.";
				}
			} else {
				$error = "Veuillez entrer une adresse e-mail valide.";
			}
		} else  {
			$error = "Veuillez entrer une adresse e-mail valide.";
		}


	} else {
		$error = "Veuillez remplit tous les champs.";
	}
}

}

?>

Good afternoon ( in france, it’s afternoon ) !

Afternoon you are only an hour ahead of London :slight_smile:

I’ve enabled debugging and when you use register.php you see the error message now


**Fatal error** : Uncaught Error: Call to undefined function execute() in /storage/ssd2/693/11368693/public_html/dev/register.php:37 Stack trace: #0 {main} thrown in  **/storage/ssd2/693/11368693/public_html/dev/register.php**  on line  **37**

Hum, i don’t do anything and the page don’t work at all :fearful:

Adding in the debug code shows errors for your site.


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Then when entering all the fields and hitting register.

https://ici-cest-la-fete.000webhostapp.com/dev/register.php

Ok, but i don’t see the problems in my code ^^

The error would

Fatal error : Uncaught Error: Call to undefined function execute() in /storage/ssd2/693/11368693/public_html/dev/register.php:37 Stack trace: #0 {main} thrown in /storage/ssd2/693/11368693/public_html/dev/register.php on line 37

Bit of Googling and you hopefully will figure it out.

I don’t find, can you corrige this ?

…The error was because i wright -, and it was ->

1 Like

This topic was automatically closed after 22 hours. New replies are no longer allowed.