BDD Issues (Insert Information)

Hello, I manage to receive information about the localhost database but on the 000webhost database nothing happens… My code:



----------------------------------------------------------- PHP -------------------------------------------------------------
<?php

$bdd = new PDO('mysql:host=localhost;dbname=id9128652_cadenas', 'id9128652_projet', 'saucisse');

if(isset($_POST['forminscription']))
{
	$pseudo = htmlspecialchars($_POST['pseudo']);
	$mail = htmlspecialchars($_POST['mail']);
	$mail2 = htmlspecialchars($_POST['mail2']);
	$mdp = sha1($_POST['mdp']);
	$mdp2 = sha1($_POST['mdp2']);

	
                     $insertmbr = $bdd->prepare("INSERT INTO membres(pseudo, mail, motdepasse) VALUES(?, ?, ?)");
                     $insertmbr->execute(array($pseudo, $mail, $mdp));
                     //$erreur = header('Location: inscription_check.php');
}
?>

-------------------------------------------------------- HTML ------------------------------------------------------------------

<html>

		<head>

            <meta charset="utf-8" />
            <link rel="stylesheet" href="css/inscription.css" />
            <link rel="icon" href="css/images/cadenas.ico" />

			<title>Cadenas Connecté | Inscription</title> 
			
		</head>

		<body>

			<header> <!-- Entête -->
				
				<div id="menu">

					<img class="logo" src="css/images/cadenas.png">
					<h2>- CADENAS CONNECTE -</h2>

					<div id="nav">
						<a href="accueil.php">ACCUEIL</a>
						<a href="inscription.php">INSCRIPTION</a>
						<a href="connexion.php">CONNEXION</a>
					</div>

				</div>

			</header>

			<h1>INSCRIPTION</h1>

			<section class="contenu"> <!-- Contenu -->
				
				<form method="POST" action=""><p class="contenu">

					<label for="pseudo">Pseudo : <input type="text" placeholder="Inserez votre pseudo" id="pseudo" name="pseudo" value="<?php if(isset($pseudo)) { echo $pseudo; }?>" /></label><br/>

					<label for="mail">Adresse e-mail : <input type="email" placeholder="Taper votre adresse-mail" id="mail" name="mail" value="<?php if(isset($mail)) { echo $mail; }?>"/></label><br/>

					<label for="mail2">Confirmation de l'e-mail : <input type="email" placeholder="Retaper votre adresse-mail" id="mail2" name="mail2" value="<?php if(isset($mail2)) { echo $mail2; }?>"/></label><br/>

					<label for="mdp">Mot de passe : <input type="password" placeholder="Inserez votre mot de passe" id="mdp" name="mdp"/></label><br/>

					<label for="mdp2">Confirmation du mot de passe : <input type="password" placeholder="Retaper votre mot de passe" id="mdp2" name="mdp2"/></label><br/>

					<input type="submit" name="forminscription" value="S'inscrire"/>

				</p></form>

				<?php
				if(isset($erreur))
				{
					echo '<font color="red">' .$erreur."</font>";
				}
				?>

			</section>
    	
    	</body>

 	</html>

What error if any do you get ?

1 Like

I have my site hosted in localhost on Wamp and I could communicate with the Wamp database (phpMyAdmin), I wanted to host my site on 000webhost, I imported the php files and the Wamp server database locallyhost to 000webhost with the file manager and the phpMyAdmin of the server. The code has not been changed except for the line mysql:host=localhost;dbname=id9128652_cadenas',id9128652_project’, sausage',sausage’ which was before mysql:host=localhost;dbname=id9128652_cadenas', id9128652_project’, `sausage’. By importing my database I have a line with id, password and username and I can connect with a page connexion.php connected to the database.

Weird, can you login to phpMyAdmin on 000webhost without any errors?

1 Like

Yep. The PHP version in Wamp : 5.5.12 and in 000webhost : 7.1.26, so I don’t know what i should do like : change the version to 000webhost or recode it in the new version with a new variable or is the version of 000webhost wich need to be at the phpMyAdmin version ?

You can turn down PHP via General Settings while logged into 000webhost?

1 Like

no i can’t turn it down but i can change the version

1 Like

why turning down php ? and how ? (on 000webhost)

You can change version via General Settings on 000webhost.com
Maybe change to 5.5? To match what you’ve got locally?

It’s good I found the solution to the problem that I didn’t really understand but good: In localhost everything was fine and yet on 000webhost, the “Avatar” column of my database was not filled at the time of registration, the database was not filled (I call this one in the profile modification but not in the registration), I could find the bug thanks to the display of it with the variable given above. In short, thank you again for your precious help.

1 Like