 |
[PHP]
ข้อมูลไม่เข้า database ครับปัญหาเกิดขึ้นจากอะไรครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
01. <?php
02.
03. ?>
04. <?php
05. $link = mysqli_connect( "localhost" , "root" , "" , "chinjung" );
06. mysqli_select_db( $link , "register_td" );
07.
08. $username = $_POST [ 'username' ];
09. $password = $_POST [ 'password' ];
10. $Firstname = $_POST [ 'Firstname' ];
11. $Lastname = $_POST [ 'Lastname' ];
12. $telephone = $_POST [ 'telephone' ];
13. $email = $_POST [ 'email' ];
14.
15. $sql = "INSERT INTO register_td(username,password,Firstname,Lastname,telephone,email) "
16. . "VALUES('$username','$password,'$Firstname','$Lastname','$telephone,'$email',)" ;
17. $objQuery = mysqli_query( $link , $sql );
18. echo "เพิ่มข้อมูลเรียบร้อยแล้ว" ;
19. ?>
Code (PHP)
01. <?php
02. $hostname = 'localhost' ;
03. $username = 'root' ;
04. $password = '' ;
05. $database = 'chinjung' ;
06.
07. $connect = new mysqli( $hostname , $username , $password , $database );
08. if ( $connect ->connect_error){
09. echo "chinjung" ;
10. }
11. ?>
Code (PHP)
01. <html>
02. <head>
03. <title>Register</title>
04. <link rel= "stylesheet" type= "text/css" href= "work/css/style1.css" >
05. <meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" >
06. </head>
07. <body>
08. <style type= "text/css" >
09. body
10. {
11. background: url(picture/bg_1.jpg) no-repeat center center fixed;
12. background-size: cover;
13. }
14. </style>
15. <div class = "registerbox" >
16. <form name= "save_register.php" method= "post" action= "save_register.php" >
17. <img src= "picture/user_m.png" class = "avatar" >
18. <h1> Register Here</h1>
19. <p>Username</p>
20. <input type= "username" name= "username" >
21. <p>Password</p>
22. <input type= "password" name= "password" >
23. <p>Firstname</p>
24. <input type= "Firstname" name= "Firstname" >
25. <p>Lastname</p>
26. <input type= "Lastname" name= "Lastname" >
27. <p>Telephone</p>
28. <input type= "telephone" name= "telephone" >
29. <p>E-mail</p>
30. <input type= "email" name= "email" >
31. <input type= "submit" name= "btn_submit" value= "Save" >
32. </form>
33. </div>
34. </body>
35. </html>
Tag : PHP, XAMPP, Windows
|
|
 |
 |
 |
 |
Date :
2018-08-20 08:42:51 |
By :
790036471203806 |
View :
702 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
01. <?php
02.
03. ?>
04. <?php
05. $link = mysqli_connect( "localhost" , "root" , "" , "chinjung" );
06. mysqli_select_db( $link , "register_td" );
07.
08. $username = $_POST [ 'username' ];
09. $password = $_POST [ 'password' ];
10. $Firstname = $_POST [ 'Firstname' ];
11. $Lastname = $_POST [ 'Lastname' ];
12. $telephone = $_POST [ 'telephone' ];
13. $email = $_POST [ 'email' ];
14.
15. $sql = "INSERT INTO register_td(username,password,Firstname,Lastname,telephone,email) "
16. . "VALUES('$username','$password,'$Firstname','$Lastname','$telephone,'$email',)" ;
17. $objQuery = mysqli_query( $link , $sql );
18. echo "เพิ่มข้อมูลเรียบร้อยแล้ว" ;
19. ?>
Code (PHP)
01. $link = mysqli_connect( "localhost" , "root" , "" , "chinjung" );
02. mysqli_query( $link , "set name utf8" );
03. if (! $link ){
04. die ( "Error connect" .mysqli_connect_error());
05.
06. }
07.
08. $sql = " INSERT INTO register_td(username,
09. password,
10. Firstname,
11. Lastname,
12. telephone,
13. email)
14. VALUES( '$username' ,
15. '$password' ,
16. '$Firstname' ,
17. '$Lastname' ,
18. '$telephone' ,
19. '$email'
20. )";
21. $objQuery = mysqli_query( $link , $sql ) or die ( "Error row::" .mysqli_error( $link ));
22. if ( $objQuery ){
23. echo "<script>alert('Save done'); <script>" ;
24. }
Basic น่ะครับ ไปอ่าน mysqli_connect และ Check ' " , ..... และวิธีการเขียนให้อ่าน Code ง่ายๆ
|
ประวัติการแก้ไข 2018-08-20 09:09:14 2018-08-20 10:47:47
 |
 |
 |
 |
Date :
2018-08-20 09:07:46 |
By :
Hararock |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ ตอนนี้ข้อมูลเข้าและครับ
|
 |
 |
 |
 |
Date :
2018-08-20 09:50:38 |
By :
790036471203806 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|