<?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>
我想将数据库中的wholw字符串显示到文本框中,但我只能显示该字符串的第一个单词。如何显示整个字符串?
我已附上2张图片供参考,请看一下。在我的数据库中,"abc xyz"
列中有sfullname
,当我选择它时,只有"abc"
显示在文本框中...请参阅图片请查看此数据库表
我想将数据库中的wholw字符串显示到文本框中,但我只能显示该字符串的第一个单词。如何显示整个字符串?
我已附上2张图片供参考,请看一下。在我的数据库中,"abc xyz"
列中有sfullname
,当我选择它时,只有"abc"
显示在文本框中...请参阅图片请查看此数据库表
答案 0 :(得分:1)
在你的第一个输入中:
<input type="text" class="form-control" name="fullname" placeholder="Fullname" value=<?php echo $row["sfullname"]; ?>>
看这里:
value=<?php echo $row["sfullname"]; ?>
您的值属性未加引号。任何空格都会产生您描述的输出。
通过正确引用修复:
value="<?php echo $row["sfullname"]; ?>"
我在这里时:
if (isset($_SESSION["session_admin"])=="" || $_SESSION["session_admin"]=="") {
header("location:index.php");
}
isset返回true或false,因此您可能需要更类似的内容:
if(!isset($_SESSION["session_admin"]) || $_SESSION["session_admin"]=="")
或者也许:
if (empty($_SESSION["session_admin"])) {
header("location:index.php");
exit;
}
不要忘记在标题重定向后退出,否则执行其余代码。
关于使用准备好的查询的强制性唠叨 - 否则你可以使用SQL注入。
答案 1 :(得分:0)
您在值属性中缺少双引号,您的代码如下所示:
<input type="text" class="form-control" name="fullname" placeholder="Fullname" value=<?php echo $row["sfullname"]; ?>>
请尝试下面的代码而不是代码:
<input type="text" class="form-control" name="fullname" placeholder="Fullname" value="<?php echo $row["sfullname"]; ?>">