Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [04-Nov-2018 15:21:52 UTC] PHP Warning: mysqli_connect(): (HY000/1045):
- Access denied for user 'freeload_retain'@'vps28004.inmotionhosting.com'
- (using password: NO) in /home/freeloadboard/public_html/insert.php on
- line 7
- [04-Nov-2018 15:21:52 UTC] PHP Warning: mysqli_select_db() expects
- parameter 1
- to be mysqli, boolean given in /home/freeloadboard/public_html/insert.php
- on line 21
- [04-Nov-2018 15:21:52 UTC] PHP Warning: mysqli_query() expects parameter
- 1 to be mysqli, boolean given in
- /home/freeloadboard/public_html/insert.php on line 45
- <?php
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
- $con = mysqli_connect('##.##.###.##','freeload_retain','');
- if(!$con)
- {
- echo "Not Connected to Server. ";
- }
- if(!mysqli_select_db($con, 'freeload_retain'))
- {
- echo "Database Not Selected. ";
- }
- $Companyname = $_POST['companyname'];
- $Username = $_POST['username'];
- $Password = $_POST['password'];
- $Email = $_POST['email'];
- $sql = "INSERT INTO clients (companyname, username, password, email)
- VALUES ('$Companyname', '$Username', '$Password', '$Email')";
- if(!mysqli_query($con, $sql))
- {
- echo "Not Inserted. ";
- }
- else
- {
- echo "Inserted. ";
- }
- ?>
- // ... Set your database connection variables
- /*
- * Create the database connection, notice the
- * usage of mysqli instead of mysql
- */
- $connect = new mysqli($host, $user, $password, $database);
- /*
- * The query, notice the usage of a question mark
- * on the place of the variables to be inserted
- */
- $sql = "INSERT INTO client (cname, tname, pname, ename) VALUES (?, ?, ?, ?)";
- // Prepare the query using $connect->prepare()
- $stmt = $connect->prepare($sql);
- // Check if the query was prepared
- if(!$stmt) {
- // ... Handle your error
- }
- // Get $_POST variables
- $companyname = $_POST['companyname'];
- $username = $_POST['username'];
- $password = $_POST['password'];
- $email = $_POST['email'];
- if(!$stmt->bind_param('ssss', $companyname, $username, $password, $email)) {
- // ... Handle your error
- }
- if(!$stmt->execute()) {
- // ... Handle your error
- } else {
- echo 'Record inserted.';
- }
- function hashPassword($password) {
- return password_hash($password, PASSWORD_DEFAULT);
- }
- function verifyPassword($password, $hash) {
- return password_verify($password, $hash);
- }
Add Comment
Please, Sign In to add comment