search

Home  >  Q&A  >  body text

PHP registration function

<?php

session_start();

$conn = mysqli_connect("localhost","root","123456","per") or die("Database Server Connection error".mysqli_connect_error()); //Connect to the database

mysqli_set_charset($conn,"utf8"); //Set the encoding format

$name=$ _POST['username']; //trim function filters spaces

$password = $_POST['pwd'];

if($name=='' ){

echo"<script>alert('Your username cannot be empty, please re-enter');location='".$_SERVER['HTTP_REFERER']. "'</script> ;";

exit;

}

if($password==''){

echo"<script>alert('You The password cannot be empty, please re-enter');location='".$_SERVER['HTTP_REFERER']. "'</script>";

exit;

}

$sql="insert into per_user form(username,password) values('$name','$password')";

$result=mysqli_query($ conn, $ sql);

IF (! $ Result) // Judging whether the data is successfully inserted into the database

{

## Echo mysqli_error ($ conn);

      }

                                              through out’s ’ out through out’s ’’s ’ through out through out through ’’s' through through through out through ’ ‐       ‐ through's''''''‐''''‐through's to 1 to 1 to 1 to 1’ to the 10th anniversary of ##                               echo "<a href='login.html'>Log in now</a>";

忧伤的大白兔忧伤的大白兔1455 days ago1105

reply all(4)I'll reply

  • 云上屹立君

    云上屹立君2021-03-05 09:44:27

    insert into per_user (username,password) values ​​($name,$password);

    Where did you see this from

    reply
    0
  • 忧伤的大白兔

    忧伤的大白兔2021-02-20 21:05:49

    The two rabbits are the username and password I typed randomly during the test

    reply
    0
  • 忧伤的大白兔

    忧伤的大白兔2021-02-20 21:03:28

    Your SQL syntax is incorrect. Check the manual corresponding to your MySQL server version for the correct syntax to use

    ## near 'form(username, password) values('rabbit', 'rabbit')' on line 1

    # After checking, this is an error message

    reply
    0
  • 路边的小蚂蚁i

    $sql="insert into per_user (username,password) values ​​('$name','$password')"; Try it this way

    路边的小蚂蚁i · 2021-02-21 16:30:12
  • Cancelreply