Last active
August 29, 2015 14:19
-
-
Save m4hi2/65c26f0ae2bb6868791e to your computer and use it in GitHub Desktop.
আমি চাচ্ছি, নতুন ইউজার এ্যাড করার আগে ঐ আইডিতে কোন ইউজার আছে কিনা সেটা চেক করতে
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $password = ""; | |
| $dbname= "crud"; | |
| //gather database credintial | |
| $servername = "127.0.0.1"; | |
| $username = "root"; | |
| //create database connection | |
| $conn = mysqli_connect($servername, $username, $password, $dbname); | |
| //Check connection | |
| if (!$conn) { | |
| die("connection failed:" . mysql_error()); | |
| } else { | |
| $id = $_POST['id']; | |
| $name = $_POST['name']; | |
| $info = $_POST['info']; | |
| //check if user exist; | |
| $checkuser = mysqli_query($conn, "SELECT id FROM test WHERE id = '$id' "); | |
| if(!$checkuser) { | |
| die("query couldn't connect" . mysql_error()); | |
| } | |
| if(mysql_num_rows($checkuser)>0) { | |
| echo "user already there"; | |
| $user = mysql_fetch_array($checkuser); | |
| print_r($user); | |
| } else { | |
| $sql = "INSERT INTO test | |
| (id, name, info) | |
| VALUES('$id', '$name', '$info')"; | |
| if(mysqli_query($conn, $sql)) { | |
| echo "bravo! Well done, bitch"; | |
| } else { | |
| echo "Something went wrong, call 01716356291, NOW!!!"; | |
| } | |
| } | |
| } | |
| ?> | |
| <html> | |
| <head> | |
| <title>processor</title> | |
| </head> | |
| <body><a href="index.php">home</a> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment