I am using form to update my database through a php file but I am getting following error in Firefox :
The character encoding of the HTML document was not declared. The
document will render with garbled text in some browser configurations
if the document contains characters from outside the US-ASCII range.
The character encoding of the page must be declared in the document or
in the transfer protocol.
And following error in Chrome:
Calling Element.createShadowRoot() for an element which already hosts
a shadow root is deprecated. See
https://www.chromestatus.com/features/4668884095336448 for more
details
A complete blank page is shown once I click the submit button with above console message.
I am attaching my html and php file for the better idea.
register.html
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Info</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="bootstrap/css/scheduler.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container container-table" >
<div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2" >
<div class="panel panel-info" style="background-color:#ccc;">
<div class="panel-heading"style="background-color:#990000;">
<div class="panel-title" style="color:white; text-align:center">Register</div>
<!-- <div style="float:right; font-size: 80%; position: relative; top:-10px">Forgot password?</div>-->
</div>
<div style="padding-top:30px" class="panel-body" >
<div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
<form action="register.php" id="loginform" class="form-horizontal" role="form" method="post">
<div style="margin-bottom: 20px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-education"></i></span>
<input id="login-username" type="text" class="form-control" name="sbuid" value="" placeholder="SBU ID">
</div>
<div style="margin-bottom: 20px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" type="text" class="form-control" name="stuName" value="" placeholder="Name">
</div>
<div style="margin-bottom: 20px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
<input id="login-username" type="text" class="form-control" name="emailID" value="" placeholder="Email ID">
</div>
<div style="margin-bottom: 20px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span>
<input id="login-username" type="text" class="form-control" name="contactInfo" value="" placeholder="Contact No.">
</div>
<div style="margin-bottom: 15px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="login-password" type="password" class="form-control" name="pass" placeholder="Password">
</div>
<div style="margin-top:10px;text-align:center" class="form-group">
<!-- Button -->
<div class="col-sm-12 controls" >
<input type = "submit" value= "Register" class="btn btn-success"></input>
</div>
</div>
</form>
<div style="text-align:center">
<strong>Sign In </strong>
</div>
</div>
</div>
</div>
</div>
<div id = "footer" class="container-fluid text-center">
<p>INFO</p>
</div>
</body>
</html>
register.php
<?php
$sbuidreg = isset($_POST['sbuid']) ? htmlspecialchars($_POST['sbuid']):"NA";
$passreg = isset($_POST['pass']) ? htmlspecialchars($_POST['pass']):"NA";
$stuNamereg = isset($_POST['stuName']) ? htmlspecialchars($_POST['stuName']):"NA";
$emailIDreg = isset($_POST['emailID']) ? htmlspecialchars($_POST['emailID']):"NA";
$contactInforeg = isset($_POST['contactInfo']) ? htmlspecialchars($_POST['contactInfo']):"NA";
$myserver = "127.0.0.1:3306"
$database = "tcpscheduler";
$password = "rootpassword";
$username = "root";
// Connect to database
$con = mysqli_connect($myserver, $username, $password, $database);
if ($con->connect_error) {
die("Connection failed: " . $con->connect_error);
}
mysqli_query($con,"INSERT INTO `loginsection` VALUES('$sbuidreg', '$passreg','$stuNamereg', '$emailIDreg','$contactInforeg')") or die("Strange Error");
echo "Account Created";
mysqli_close($con);
header('Location: index.html');
?>
Related
I created new inquiry form for my website. But it's giving the following error message.
Error
Sorry there was an error sending your form.
mail:Could not instantiate mail function.
Form HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PHP Contact Form Script With Validation - reusable form</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="form.css" >
<script src="form.js"></script>
</head>
<body >
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h2>Contact Us</h2>
<p> Send us your message and we will get back to you as soon as possible </p>
<form role="form" method="post" id="reused_form">
<div class="row">
<div class="col-sm-6 form-group">
<label for="name"> First Name:</label>
<input type="text" class="form-control" id="firstname" name="firstname" maxlength="50">
</div>
<div class="col-sm-6 form-group">
<label for="name"> Last Name:</label>
<input type="text" class="form-control" id="lastname" name="lastname" maxlength="50">
</div>
</div>
<div class="row">
<div class="col-sm-6 form-group">
<label for="email"> Email:</label>
<input type="text" class="form-control" id="email" name="email" maxlength="50">
</div>
<div class="col-sm-6 form-group">
<label for="email"> Phone:</label>
<input type="tel" class="form-control" id="phone" name="phone" required maxlength="50">
</div>
</div>
<div class="row">
<div class="col-sm-12 form-group">
<label for="name"> Message:</label>
<textarea class="form-control" type="textarea" id="message" name="message" placeholder="Your Message Here" maxlength="6000" rows="7"></textarea>
</div>
</div>
<div class="row">
<div class="col-sm-12 form-group">
<button type="submit" class="btn btn-lg btn-success btn-block" id="btnContactUs">Post It! </button>
</div>
</div>
</form>
<div id="success_message" style="width:100%; height:100%; display:none; "> <h3>Sent your message successfully!</h3> </div>
<div id="error_message" style="width:100%; height:100%; display:none; "> <h3>Error</h3> Sorry there was an error sending your form. </div>
</div>
</div>
</div>
</body>
</html>
Handler.php:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/*
Tested working with PHP5.4 and above (including PHP 7 )
*/
require_once './vendor/autoload.php';
use FormGuide\Handlx\FormHandler;
$pp = new FormHandler();
$validator = $pp->getValidator();
$validator->fields(['firstname','lastname', 'email','phone'])->areRequired()->maxLength(50);
$validator->field('email')->isEmail();
$validator->field('message')->maxLength(6000);
$pp->sendEmailTo('name#mail.com'); // ← Your email here
echo $pp->process($_POST);
You are not defining an action for the form.
<form role="form" method="post" id="reused_form" action="Handler.php">
<!-- html goes here -->
</form>
<?php
include "dbconfig.php";
session_start();
if (isset($_SESSION["session_admin"])=="" || $_SESSION["session_admin"]=="") {
header("location:index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Edit</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="stylesheet" type="text/css" href="bootstrap.css">
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style type="text/css">
.form-control
{
width: 300px;
/*text-transform: uppercase;*/
}
.email
{
/*ext-transform: lowercase;*/
}
.btn
{
color: white;
}
.error{
color: red;
}
.right-addon input { padding-right: 0px; }
.right-addon .glyphicon { right: 0px;}
</style>
</head>
<script type="text/javascript">
</script>
<body>
<div class="container">
<div class="panel panel-info">
<div class="panel-heading">
<center><strong><h2>Edit</h2></strong></center>
</div>
<div class="panel-body">
<?php
$get_id=$_GET["id"];
$result=mysqli_query($db,"select * from signup where sid=$get_id");
while ($row=mysqli_fetch_array($result)) {
?>
<form method="post" id="signup" role="form">
<div class="row">
<div class="form-group col-xs-7">
<div class="inner-addon left-addon">
<span class="glyphicon glyphicon-user"></span>
<input type="text" class="form-control" name="fullname" placeholder="Fullname" value=<?php echo $row["sfullname"]; ?>>
</div>
</div>
<div class="form-group col-xs-3">
<div class="inner-addon left-addon">
<span class="glyphicon glyphicon-envelope"></span>
<input type="text" class="form-control email" name="email" placeholder="Email address">
</div>
</div>
<div class="form-group col-xs-7">
<div class="inner-addon left-addon">
<span class="glyphicon glyphicon-earphone"></span>
<input type="text" class="form-control" name="mobile" placeholder="Mobile number">
</div>
</div>
<div class="form-group col-xs-3">
<div class="inner-addon left-addon">
<input type="date" class="form-control" name="dob">
</div>
</div>
<div class="form-group col-xs-7">
<div class="inner-addon left-addon">
<span class="glyphicon glyphicon-map-marker"></span>
<input type="text" class="form-control" name="address" placeholder="Address">
</div>
</div>
<div class="form-group col-xs-3">
<select class="form-control" name="state" style="width: 100px;" >
<option value="">State</option>
<option>Gujrat</option>
<option>Maharashtra</option>
<option>Goa</option>
<option>Rajasthan</option>
</select>
</div>
<div class="form-group col-xs-7">
<div class="inner-addon right-addon">
<input type="password" id="password" class="form-control" name="createpass" placeholder="Create password">
</div>
</div>
<div class="form-group col-xs-3">
<select class="form-control" name="city" style="width: 100px;" >
<option value="">City</option>
<option>Ahmedabad</option>
<option>Mumbai</option>
<option>Kolkata</option>
<option>Delhi</option>
<option>Banglore</option>
<option>Chennai </option>
</select>
</div>
<div class="form-group col-xs-7">
<div class="inner-addon right-addon">
<input type="password" class="form-control" name="confirmpass" placeholder="Confirm password">
</div>
</div>
<div class="form-group col-xs-3">
<strong>Gender</strong>
<input type="radio" name="gender" value="Male">Male
<input type="radio" name="gender" value="Female">Female
</div>
</div>
<div class="form-group ">
<center>
<!-- <input type="submit" name="sbt" value="Register" class="form-control btn-success"> -->
<button type="submit" name="sbt" class="btn"><span style="color: white;">Update</span></button>
</center>
</div>
</form>
<?php }?>
</div>
</div>
<!-- Jquery Plugin CDN -->
<script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- Jquery Validation Plugin CDn -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jquery-validation#1.17.0/dist/jquery.validate.js"></script>
<!-- Linking Page to index.js for form validation -->
<script type="text/javascript" src="index.js"></script>
</body>
</html>
I want to display wholw string from my database into textbox but I am only able to display first word of that string. How can I display the whole string?
I have attached 2 images for reference, please look at them. In my database there is "abc xyz" in sfullname column and when I am selecting it only "abc" is displaying in the textbox...please refer images Please look this Database table
I want to display wholw string from my database into textbox but I am only able to display first word of that string. How can I display the whole string?
I have attached 2 images for reference, please look at them. In my database there is "abc xyz" in sfullname column and when I am selecting it only "abc" is displaying in the textbox...please refer images Please look this Database table
In your first input look here:
value=<?php echo $row["sfullname"]; ?>
Your value attribute is unquoted. Any spaces will result in the output you describe. Besides, it should be html-escaped as well, as a stray quote in the data will result in the same behavior.
Fix by quoting correctly:
value="<?php echo htmlspecialchars($row["sfullname"], ENT_QUOTES); ?>"
While I am here. empty() fits better for your if statement, so you probably want something more like:
if (empty($_SESSION["session_admin"])) {
header("location:index.php");
exit;
}
Don't forget to exit after a header redirection, else the rest of your code is executed.
Plus mandatory nag about using prepared queries - else you are open to SQL injection.
You are missing double quotes in the value attributes, your code looks like:
<input type="text" class="form-control" name="fullname" placeholder="Fullname" value=<?php echo $row["sfullname"]; ?>>
Plese try below one instead of your code:
<input type="text" class="form-control" name="fullname" placeholder="Fullname" value="<?php echo $row["sfullname"]; ?>">
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
The following code gives a signup form that i created but unfortunately though it works the mysql query fails and returns the error message unsuccessfull signup! how can i correct this?
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Theme Made By www.w3schools.com - No Copyright -->
<title>Arsiri Textile </title>
<meta charset="utf-8">
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Theme Made By www.w3schools.com - No Copyright -->
<title>Arsiri Textile </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/basic.css">
<style>
</style>
</head>
<body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="60">
<div class="header" style="height:60px;background:#330d00;width:1350px">
<a class="navbar-brand" href="#myPage">ARSIRI TEXTILE |</a>
<ul class="nav navbar-nav navbar-left">
</ul>
<ul class="nav navbar-nav navbar-right">
<li>About Us</li>
<li>Contact Us</li>
<li>Login</li>
<li> Signup</li>
</ul>
</div>
<div class="image" style="height:530px; width:1350px" >
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css" />
</head>
<body>
<div class="panel panel-default">
<div class="panel-heading" style="background:#330d00;">
<h3 class="panel-title">Customer Registration</h3><br>
</div>
<div class="panel-body" >
<form class="form-horizontal" role="form" action="signupaction.php" method="post" >
<div class="form-group">
<label for="name" class="col-sm-2 control-label">First Name</label>
<div class="col-sm-10" style="width:300px">
<input type="text" class="form-control" id="name" name="firstname" required>
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Last Name</label>
<div class="col-sm-10" style="width:300px">
<input type="text" class="form-control" id="name" name="lastname" required>
</div>
</div>
<div class="form-group">
<label for="Address" class="col-sm-2 control-label">Address</label>
<div class="col-sm-10" style="width:300px">
<textarea class="form-control" class="form-control" name="address"></textarea>
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Contact No.</label>
<div class="col-sm-10" style="width:300px">
<input type="text" maxlength="10" class="form-control" id="name" name="contactno" required>
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">E-Mail</label>
<div class="col-sm-10" style="width:300px">
<input type="email" class="form-control" id="name" name="emailaddress" required>
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10" style="width:300px">
<input type="password" class="form-control" id="pass" name="password" required>
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Confirm password
</label>
<div class="col-sm-10" style="width:300px">
<input type="password" class="form-control" id="confirmpass" name="cpassword" required><br>
</div>
</div>
<div class="panel-footer" style="overflow:hidden;text-align:left;">
<div class="col-sm-offset-2 col-sm-10">
<input class="btn btn-success btn-sm" type=submit name=submit value=Submit >
<input class="btn btn-success btn-sm" type=reset name=reset value=Cancel>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</div>
<div class="footer " style="background:#330d00; height:60px ;width:1350px ">
<p align="center" > Asiri all rights reserved</p>
</div>
The relevant php script(ignupaction.php) for the above html form is as follows
<?php
//importing db.php in the includes folder
require("includes/db.php");
$fname=$_POST["firstname"];
$lname=$_POST["lastname"];
$address=$_POST["address"];
$contact=$_POST["contactno"];
$email=$_POST["emailaddress"];
$password=$_POST["password"];
$cpassword=$_POST["cpassword"];
$sql="INSERT INTO `signup` VALUES ('$fname','$lname','$address','$contact','$email','$password',$cpassword')";
$result=mysqli_query($db,$sql);
if(!$result){
echo "Unsuccessful signup";
}
else{
echo "Successful signup";
}
?>
when the form is submitted it returns unsuccessful signup! how can i correect this?
$sql="INSERT INTO signup VALUES ('$fname','$lname','$address','$contact','$email','$password',$cpassword')";
you are missing a ' on the last variable. you have '$password',$cpassword' <----- missing '. Also change the ticks around 'signup'.
Try this :
$sql="INSERT INTO 'signup' VALUES ('$fname','$lname','$address','$contact','$email','$password','$cpassword')";
<html>
<head>
<title>
Installation
</title>
<script src="public/js/jquery-1.9.0.min.js"></script>
<script src="public/js/bootstrap3/js/bootstrap.js"></script>
<link media="all" type="text/css" rel="stylesheet" href="public/js/bootstrap3/css/bootstrap.min.css">
<link media="all" type="text/css" rel="stylesheet" href="public/js/bootstrap3/css/font-awesome.min.css">
<link media="all" type="text/css" rel="stylesheet" href="public/js/bootstrap3/css/main.css">
</head>
<body>
<div
class="navbar navbar-default navbar-fixed-top">
<div
class="container">
<div
class="navbar-header">
<button
type="button"
class="navbar-toggle"
data-toggle="collapse"
data-target=".navbar-collapse">
<span
class="icon-bar"></span>
<span
class="icon-bar"></span>
<span
class="icon-bar"></span>
</button>
<a
class="navbar-brand"
href="<?php // echo base_url()?>">Kingpabel
ATN</a>
</div>
<div
class="navbar-collapse collapse">
</div>
<!--/.nav-collapse -->
</div>
</div>
<div
class="rc">
<div
class="container main">
<div
class="col-md-3">
</div>
<div
class="col-md-6">
<form
method="post"
accept-charset="utf-8"
role="form"
class="form- signin form-horizontal">
<h2
class="form-signin-heading">Installation</h2>
<div
style="margin-top: 20px;">
<label
for="host_name"
class="col-sm-3 control-label"
style="color: black">
Host
Name
</label>
<div
class="input text database_host col-md-9">
<input
type="text"
name="host_name"
class="form-control"
placeholder="Database Host Name"
autofocus=""
required="required"
id="host_name">
</div>
</div>
<div>
<label
for="database_name"
class="col-sm-3 control-label"
style="color: black">
Database
Name
</label>
<div
class="input text database_name col-md-9">
<input
type="text"
name="database_name"
class="form-control"
placeholder="Database Name"
autofocus=""
required="required"
id="database_name">
</div>
</div>
<div>
<label
for="user_name"
class="col-sm-3 control-label"
style="color: black">
User
Name
</label>
<div
class="input text user_name col-md-9">
<input
type="text"
name="user_name"
class="form-control"
placeholder="Database User Name"
autofocus=""
required="required"
id="user_name">
</div>
</div>
<div>
<label
for="password"
class="col-sm-3 control-label"
style="color: black">
Password
</label>
<div
class="input text password col-md-9">
<input
type="password"
name="password"
class="form-control"
placeholder="Database Password"
autofocus=""
id="password">
</div>
</div>
<div>
<label
for="project_url"
class="col-sm-3 control-label"
style="color: black">
Project
Url
</label>
<div
class="input text project_url col-md-8 input-group input-group-sm">
<input
style=" margin-left: 13px;"
type="text"
name="project_url"
class="form-control"
placeholder="Project URL"
autofocus=""
id="project_url"
aria-describedby="basic-addon2">
<span
class="input-group-btn">
<button
class="btn btn-default"
type="button"
style="margin-top: -15px;">/public</button>
</span>
</div>
</div>
<button
type="submit"
class="btn btn-lg btn-login btn-block">Install</button>
</form>
</div>
</div>
</div>
<section
id="bottom"
style="margin-top: 50px">
</section>
<footer
id="footer">
<div
class="container">
<div
class="footer">
<div
class="row">
<div
class="col-md-12">
</div>
</div>
</div>
</div>
</footer>
</body>
</html>
<?php
if ($_POST) {
$envFile = file_get_contents('.env');
if (isset($_POST['host_name']) && $_POST['host_name'])
$envFile = str_replace('DB_HOST=localhost', "DB_HOST= {$_POST['host_name']}", $envFile);
if (isset($_POST['database_name']) && $_POST['database_name'])
$envFile = str_replace('DB_DATABASE=homestead', "DB_DATABASE={$_POST['database_name']}", $envFile);
if (isset($_POST['user_name']) && $_POST['user_name'])
$envFile = str_replace('DB_USERNAME=homestead', "DB_USERNAME={$_POST['user_name']}", $envFile);
if (isset($_POST['password']) && $_POST['password'])
$envFile = str_replace('DB_PASSWORD=secret', "DB_PASSWORD={$_POST['password']}", $envFile);
file_put_contents('.env', $envFile);
if (isset($_POST['project_url']) && $_POST['project_url']) {
file_get_contents('index.php');
file_put_contents('index.php', "<?php
header('Location: {$_POST['project_url']}/public');
");
}
}`
In above code, after submitting the form, the idex.php is rewriiten and changes. And i wanted to redirect to another page after submitting the form. But it is not being redirected.
Not sure what all your block of codes are for but perhaps try this..
On your
if (isset($_POST['project_url']) && $_POST['project_url']) {
file_get_contents('index.php');
file_put_contents('index.php', "<?php
header('Location: {$_POST['project_url']}/public');
");
}
change to
if (isset($_POST['project_url']) && $_POST['project_url']) {
$url = $_POST['project_url'] + '/public';
header('Location: $url');
}
Hi guys I started creating a website 2 months ago and just a week before I hit rock bottom in making it. My problem is that I can't get it to add data to my SQL database which I created using the SQL database and phpmyadmin provided with my 000webhost.com package.
Here is my PHP code with HTML at the bottom:
<?php
$con=mysqli_connect("mysql11.000webhost.com","xxxxxxxx","xxxxxxxxx","xxxxxxxx");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$mysqli_query("INSERT INTO userreg (email,password,name)
VALUES ('Peterbaob#gmail.com', 'gigtit',bob_name)");
echo"adding is done";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Friend It sign up</title>
<link rel="stylesheet" type="text/css" href=" css/bootstrap.css">
<link rel="stylesheet" type="text/css" href=" css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.css">
<link rel="stylesheet" type="text/css" href=" css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href=" css/index.css">
</head>
<body>
<ul class="nav nav-pills">
<li>Home</li>
<li>About</li>
<label class="web-name">Friend It</label>
</ul>
<div class="page-header">
<h1>Sign up</h1>
</div>
<div class="container">
<div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-col-sm-8 col-sm-offset-2">
<div class="panel panel-primary" >
<div class="panel-heading">
<div class="panel-title">Sign up</div>
</div>
<div style="padding-top:30px" class="panel-body" >
<from action="connect.php" method="post">
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" name="user" type="text" class="form-control" name="username" value="" placeholder="email">
</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i></span>
<input id="login-username" type="text" name="fullname" class="form-control" name="username" value="" placeholder="Full Name">
</form>
</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="login-password" name="pass" type="password" class="form-control" name="password" placeholder="Password">
</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-repeat"></i></span>
<input id="login-password" type="password" class="form-control" name="passwordre" placeholder="Re-type Password">
</div>
<div style="margin-top:10px" class="form-group">
<div style="margin-left:140px" class="col-sm-12 controls">
<a id="btn-signup" href="connect.php" class="btn btn-primary" type="submit">Sign up</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
You can also check out the website by going to friendit.meximas.com
the function is mysqli_query() not $mysqli_query(), I don't know why the others did not catch this.
mysqli_query("INSERT INTO userreg (email,password,name)
VALUES ('Peterbaob#gmail.com', 'gigtit', 'bob_name')");
Since its the procedural style you can pass the connection as the first parameter:
mysqli_query($con, "INSERT INTO userreg (email,password,name)
VALUES ('Peterbaob#gmail.com', 'gigtit', 'bob_name')");
Try this query, I think only problem is value for name column should be wrapped by single quote, which is missing.
$mysqli_query("INSERT INTO userreg (email,password,name)
VALUES ('Peterbaob#gmail.com', 'gigtit','bob_name')");
Hope this help :)
the problem is in your query, try this one:
$mysqli_query("INSERT INTO userreg (email,password,name)
VALUES ('Peterbaob#gmail.com', 'gigtit','bob_name')");
for your second error (edit: Which you posted as a comment) its about wrong parenthesis
you can check PHP Error: Function name must be a string
or post that line which cause the error.