我目前有一个PHP表单供我们的合作伙伴注册报价。用户登录后,它们将被带到报价表的开头。我希望用户的名字自动显示在第一个表单字段中。
用户的会话信息包括一系列值;其中一个是firstName值。这是我想在用户登录时在第一个字段中显示的值。
当我尝试加载页面时,我收到错误而不是用户的名字。
这是我得到的错误:
注意:未定义的索引: C:\ wamp64 \ www \ quote_generator \ quote_tool.php 中的用户 77
以下是更新的网页代码:
<?php
require("config.php");
if(empty($_SESSION['user']))
{
header("Location: index.php");
die("Redirecting to index.php");
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Quoting Tool </title>
<meta name="description" content="Teo partner quote generator tool">
<meta name="Kenneth Carskadon" content="www.kencarskadon.com">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSS -->
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
<link rel="stylesheet" href="assets/css/bootstrap.min.css" media="screen">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/3.1.3/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="assets/css/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="assets/css/form-elements.css">
<link rel="stylesheet" href="assets/css/datepicker.css">
<link rel="stylesheet" href="assets/css/style.css">
<style>
body {
background: url("assets/images/backgrounds/background.jpg") no-repeat fixed center;
background-size: cover;
}
</style>
</head>
<body>
<!-- Top menu -->
<nav class="navbar navbar-inverse navbar-no-bg" role="navigation">
<div class="container">
<div>
<a class="navbar-brand" href="#">
<img src="assets/images/logo/Teo%20Logo%20White.png" class="img-responsive" id="teo-logo">
</a>
</div>
</div>
</nav>
<!-- Top content -->
<div class="top-content">
<div class="inner-bg">
<div class="container form-container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2 text">
<h1><strong>Teo</strong> Partner Quote Generation Form</h1>
</div>
</div>
<div class="row">
<div class="col-sm-8 col-sm-offset-2 form-box">
<form role="form" action="" method="post" class="registration-form">
<!-- Fieldset 1: Partner Information -->
<fieldset>
<div class="form-top">
<div class="form-top-left">
<h2>Partner Information</h2>
<h3>Tell us who you are</h3>
</div>
<div class="form-top-right">
<img src="assets/images/icons/partner_info.png" class="form-icon">
</div>
</div>
<div class="form-bottom">
<div class="form-group">
<input type="text" name="form-partner-name" placeholder="Partner name" class="form-partner-name form-control" id="form-partner-name"
value="<?php echo $_POST['user']['firstName']?>">
</div>
<div class="form-group">
<select name="partner-level" type="text" title="Select partner level" class="form-control" id="form-partner-level" >
<option>Select partner level</option>
<option data-price="34">Platinum</option>
<option data-price="32">Gold</option>
<option data-price="29">Silver</option>
</select>
</div>
<div class="form-group">
<input type="text" readonly="readonly" name="discount-perc" placeholder="Discount(%)" class="form-control" id="form-discount-perc">
</div><br />
<div class="form-group">
<input type="text" name="form-margin-perc" placeholder="Margin(%)" class="form-control" id="form-margin-perc">
</div>
<br /><br />
<button type="button" class="btn btn-next">Next</button>
</div>
</fieldset>
<!-- Fieldset 2: Quote Information -->
<fieldset>
<div class="form-top">
<div class="form-top-left">
<h2>Quote Information</h2>
<h3>Tell us about your customer</h3>
</div>
<div class="form-top-right">
<img src="assets/images/icons/partner_info.png" class="form-icon">
</div>
</div>
<div class="form-bottom">
<div class="form-group">
<input type="text" name="form-customer-name" placeholder="Customer name" class="form-customer-name form-control" id="form-customer-name">
</div>
<div class="form-group">
<input type="text" name="form-quote-number" placeholder="Quote Number" class="form-quote-number form-control" id="form-quote-number">
</div>
<div class="form-group">
<input type="text" name="form-incentive-exp" placeholder="Incentive Expiration Date" class="teo-datepicker">
</div>
<div class="form-group">
<input type="text" name="form-proposal-exp" placeholder="Proposal Expiration Date" class="teo-datepicker">
</div>
<br /><br />
<button type="button" class="btn btn-previous">Previous</button>
<button type="button" class="btn btn-next">Next</button>
</div>
</fieldset>
<!-- Fieldset 3: Select Servers -->
<fieldset>
<div class="form-top">
<div class="form-top-left">
<h2>Select Servers</h2>
<h3>Tell us about the servers you need</h3>
</div>
<div class="form-top-right">
<img src="assets/images/icons/select_servers.png" class="form-icon">
</div>
</div>
<div class="form-bottom">
<div class="form-group">
<label for="server-select">What kind of server do you need?</label>
<select class="form-control" id="server-type-select">
<option>Please select and option below</option>
<option>Pro Server</option>
<option>Mini Server</option>
</select>
</div>
<div class="form-group">
<label for="server-select">How many servers do you need?</label>
<input type="text" name="form-server-quantity" placeholder="Number of servers" class="form-control" id="form-server-quantity">
</div>
<br /><br />
<button type="button" class="btn btn-previous">Previous</button>
<button type="button" class="btn btn-next">Next</button>
<button type="button" class="btn btn-skip">skip</button>
</div>
</fieldset>
<!-- Fieldset 4: Configure Servers -->
<fieldset>
<div class="form-top">
<div class="form-top-left">
<h2>Select Servers</h2>
<h3>Tell us about the servers you need</h3>
</div>
<div class="form-top-right">
<img src="assets/images/icons/select_servers.png" class="form-icon">
</div>
</div>
<div class="form-bottom">
<div class="form-group">
<label for="server-select">What kind of server do you need?</label>
<select class="form-control" id="server-type-select">
<option>Please select and option below</option>
<option>Pro Server</option>
<option>Mini Server</option>
</select>
</div>
<div class="form-group">
<label for="server-select">How many servers do you need?</label>
<input type="text" name="form-server-quantity" placeholder="Number of servers" class="form-control" id="form-server-quantity">
</div>
<br /><br />
<button type="button" class="btn btn-previous">Previous</button>
<button type="button" class="btn btn-next">Next</button>
<button type="button" class="btn btn-skip">Skip</button>
</div>
</fieldset>
<div class="btn-logout">
<a href="logout.php">Logout</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Javascript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.backstretch.min.js"></script>
<script type='text/javascript' src="https://rawgit.com/RobinHerbots/jquery.inputmask/3.x/dist/jquery.inputmask.bundle.js"></script>
<script src="assets/js/bootstrap-datepicker.js"></script>
<script src="assets/js/scripts.js"></script>
<!--[if lt IE 10]>
<script src="assets/js/placeholder.js"></script>
<![endif]-->
</body>
</html>
更新:我有一个会话页面,向我展示当前会话的相关信息,这些是我正在谈论的表单的结果:
答案 0 :(得分:0)
截图澄清了它。
你应该可以使用
$session['user']['firstName']
如上面的评论中所述,您将希望迁移使用具有安全隐患的eval
。