Ciao, ho letto le guide.
Ho provato a fare un database, usando mysql workbanch.
Adesso provavo a utilizzare un form ( nome ,cognome, professione, email)
e voglio far connettere il form con il database tramite una pagina php.
codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html"; charset="iso-8859-1"> <title>Giuseppe</title> </head> <body bgcolor="orange" text="green" > <form name="dati utente" action="database.php" method="post"> <fieldset> <legend>Dati Utente</legend> <label>Nome:</label> <input name="nome" type="text" size="20" maxlength="30" /> <label>Cognome:</label> <input name="cognome" type="text" size="20" maxlength="30" /> <label>Professione:</label> <input name="professione" type="text" size="20" maxlength="30" /> <label>Email:</label> <input name="email" type="text" size="20" maxlength="30" /> </fieldset> <button type="reset">annulla</button> <button type="submit">invia</button> </form> </body> </html>codice:<?php $con = mysql_connect("localhost","Giuseppe","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $sql="INSERT INTO persona (FirstName, LastName, professione,email) VALUES ('$_POST[nome]','$_POST[cognome]','$_POST[professione]','$_POST[email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?>

Rispondi quotando