2014-11-17 5 views

ответ

1

Сначала вам нужен вид:

<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <title> my title </title> 
 
    <meta charset = "utf-8" /> 
 
    </head> 
 
    <body> 
 
    <form action = "myfile.php" method = "post"> 
 
     <input type = "text" placeholder = "id" name = "id" /> 
 
     <input type = "text" placeholder = "password" name = "password" /> 
 
     <input type = "submit" /> 
 
    </form> 
 
    </body> 
 
</html>

Это один просто создать форму с двумя входными для идентификатора & прохода.

Теперь вам нужно написать myfile.php сказать ему, чтобы сделать запрос:

<?php 
    $userId = $_POST['id']; // The id is the name of the input 
    $userPassword = $_POST['password']; 

    $mytable = "yourTableNameHere"; // You need to create it first with right columns names (in this example, id & pass) 
    $myServer = "yourServerNameHere"; // localhost by default 
    $myUserName = "yourUserNameHere"; // name entered to access your database 
    $myPassword = "yourPassWordHere" // password used to access your database 
    $myDataBase = "yourDataBaseName"; 

    $myQuery = "INSERT INTO " . $mytable . " (id, pass) VALUES('" . $userId . "', '" . $userPassword . "');"; 

    $mysqli = new mysqli($myServer, $myUserName, $myPassword, $myDataBase); 

    $mysqli->query($myQuery); // your query is executed here 
?> 

 Смежные вопросы

  • Нет связанных вопросов^_^