Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Formulario De Contacto</title>
- <link rel="stylesheet" type="text/css" href="estilo.css">
- </head>
- <body>
- <div class="form">
- <form action="guardar.php" method="POST">
- <p>Nombre</p>
- <label for="nombre">Su nombre</label>
- <br>
- <input type="text" name="user" required>
- <p>Correo</p>
- <label for="correo">Direccion De Correo</label>
- <br>
- <input type="password" name="pass" required>
- <br>
- <br>
- <input type="submit" value="Enviar">
- </form>
- </div>
- </body>
- </html>
- <?php
- //conectamos Con el servidor
- $conectar=@mysql_connect('localhost','Usuario','Contraseña');
- //verificamos la conexion
- if(!$conectar){
- echo"No Se Pudo Conectar Con El Servidor";
- }else{
- $base=mysql_select_db('NombreBaseDeDatos');
- if(!$base){
- echo"No Se Encontro La Base De Datos";
- }
- }
- //recuperar las variables
- $user=$_POST['user'];
- $pass=$_POST['pass'];
- //hacemos la sentencia de sql
- $sql="INSERT INTO datos VALUES('$user',
- '$pass')";
- //ejecutamos la sentencia de sql
- $ejecutar=mysql_query($sql);
- //verificamos la ejecucion
- if(!$ejecutar){
- echo"Hubo Algun Error";
- }else{
- echo"Datos Guardados Correctamente<br><a href='index.html'>Volver</a>";
- }
- ?>
Add Comment
Please, Sign In to add comment