PHP unwanted autosubmit - php

I have this list of DB entries in HTML and I wanted a edit button next to each row to be able to update the users info. The POST variables get to the .php file that updates the database row, the problem is that I can only edit the last row of the list, it seems like it submits the data via POST automatically. I would like to submit the data only after the Edit button has been pressed.
Show current member info and on-click redirect to a .php file where the query itself is executed
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("users") or die(mysql_error());
$id = $_POST['id'];
$query = "SELECT * FROM userinfo WHERE id LIKE $id";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/font-awesome.css">
<script src="js/jquery-2.1.4.js"></script>
<script src="js/bootstrap.js"></script>
</head>
<body>
<div class="container">
<div class="well">
<form action="edit.php" class="form-horizontal well" method="post">
<fieldset>
<legend>Edit a member</legend>
<div class="row">
<div class="col-xs-8">
<div class="form-group">
<div class="rows">
<div class="col-md-8">
<div class="col-lg-6">
<input class="form-control input-lg" id="name" name="name" value="<?php echo $row['name'] ?>" type="text">
</div>
<div class="col-lg-6">
<input class="form-control input-lg" id="surname" name="surname" value="<?php echo $row['surname'] ?>" type="text">
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="rows">
<div class="col-md-8">
<div class="col-lg-12">
<input class="form-control input-lg" id="address" name="address" value="<?php echo $row['address'] ?>" type="text">
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="rows">
<div class="col-md-8">
<div class="col-lg-12">
<input class="form-control input-lg" id="number" name="number" value="<?php echo $row['number'] ?>" type="text">
<input type='hidden' name='id' value="<?php echo $row['id'] ?>">
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="rows">
<div class="col-md-8">
<div class="col-lg-12">
<button class="btn btn-success btn-lg" type="submit">Update member details</button>
<div class="btn btn-info">View member DB</div>
</div>
</div>
</div>
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div><!-- /container -->
</body>
</html>
Listing of current users (db rows)
<!DOCTYPE html>
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("users") or die(mysql_error());
?>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/font-awesome.css">
<script src="js/jquery-2.1.4.js"></script>
<script src="js/bootstrap.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="well">
<h2 class="text-center">List of members</h2>
<hr width="75%">
<table class="table table-striped">
<thead>
<th width="6%" align="left">Member ID</th>
<th width="7%" align="left">First Name</th>
<th width="7%" align="left">Last Name</th>
<th width="7%" align="center">Address</th>
<th width="7%" align="center">Number</th>
<th width="7%" align="center">Edit</th>
</thead>
<tbody>
<?php
$query = 'SELECT * FROM userinfo';
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)){
echo ' <tr> ';
echo ' <td> ';
echo $row['id'];
echo ' <td> ';
echo $row['name'];
echo ' <td> ';
echo $row['surname'];
echo ' <td> ';
echo $row['address'];
echo ' <td> ';
echo $row['number'];
echo "<td><form action='info.php' method='POST'><input type='hidden' name='id' value='".$row['id']."'/><input type='submit' name='submit-btn' value='View/Update Details' /><form></td></tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="btn btn-info">Insert a new member</div>
<div class="btn btn-danger">Clear table</div>
</div>
</body>
</html>
Thanks for the help.

Replace
<form>
with
</form>
to end the form properly, otherwise it will be seen as only one form and the values of the last row will be used, since they are duplicated (one form contains all fields)

replace your edit buttom code.
echo "<td><form action='info.php' method='POST'><input type='hidden' name='id' value='".$row['id']."'/><input type='submit' name='submit-btn' value='View/Update Details' /><form></td></tr>";
with this code
echo '<a href="update.php/'. $row["id"].'"';

Related

Columns wont align Horizontally in Bootstrap 5

Im trying to make a Shopping Cart using php and Bootstrap 5. I specified the classes but the items still stacks vertically. I want it to be beside each other and align Horizontally
<!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.0">
<title>shopping cart</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<link rel="stylesheet" href="cart.css">
</head>
<body>
<div class="container">
<?php
$connect = mysqli_connect('localhost','root','1234','cart');
$query = 'SELECT * FROM products ORDER by id ASC';
$result = mysqli_query($connect, $query);
if ($result) {
if(mysqli_num_rows($result)>0){
while($product = mysqli_fetch_assoc($result)){
?>
<div class="row">
<div class="col-sm-4 col-md-3">
<form method="post" action="index.php?action=add&id=<?php echo $product['id']; ?>">
<div class="products">
<img class="img-fluid" src="<?php echo $product['image']; ?>">
<h4 class="text-info"><?php echo $product['name']; ?></h4>
<h4>$ <?php echo $product['price']; ?></h4>
<input type="text" name="quantity" class="form-control" value="1" />
<input type="hidden" name="name" value="<?php echo $product['name']; ?>"/>
<input type="hidden" name="price" value="<?php echo $product['price']; ?>"/>
<input type="submit" name="add_to_cart" class="btn btn-info" value="Add to Cart"/>
</div>
</form>
</div>
</div>
<?php
}
}
}
?>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
</body>
</html>
is there something that im missing?? I tried evrything that i know of T^T
ps. Im still a novice when it comes to Web Developing so please have mercy on me T^T ;3
You have a "row" around each "column", that means each row has only one column. Try to put the "row" outside the loop so multiple columns fall within it. You can have as many columns in a row as you like. Something like this:
<?php
if ($result) {
if(mysqli_num_rows($result)>0){
?>
<div class="row">
<?php
while($product = mysqli_fetch_assoc($result)){
?>
<div class="col-sm-4 col-md-3">
<form method="post" action="index.php?action=add&id=<?php echo $product['id']; ?>">
<div class="products">
<img class="img-fluid" src="<?php echo $product['image']; ?>">
<h4 class="text-info"><?php echo $product['name']; ?></h4>
<h4>$ <?php echo $product['price']; ?></h4>
<input type="text" name="quantity" class="form-control" value="1" />
<input type="hidden" name="name" value="<?php echo $product['name']; ?>"/>
<input type="hidden" name="price" value="<?php echo $product['price']; ?>"/>
<input type="submit" name="add_to_cart" class="btn btn-info" value="Add to Cart"/>
</div>
</form>
</div>
<?php
}
?>
</div>
<?php
}
}
?>
</div>
<?php
if (mysqli_num_rows($result) > 0) {
echo '<div class="row">';
while ($product = mysqli_fetch_assoc($result)) {
?>
<div class="col-sm-4 col-md-3">
<form method="post" action="index.php?action=add&id=<?php echo $product['id']; ?>">
<div class="products">
<input type="hidden" name="name" value="<?php echo $product['name']; ?>" />
<input type="hidden" name="price" value="<?php echo $product['price']; ?>" />
<!-- I think you need rows inside form tag -->
<div class="row">
<div class="col-sm-4 col-md-3">
<img class="img-fluid" src="<?php echo $product['image']; ?>">
</div>
<div class="col-sm-4 col-md-3">
<h4 class="text-info"><?php echo $product['name']; ?></h4>
</div>
<div class="col-sm-4 col-md-3">
<h4>$ <?php echo $product['price']; ?></h4>
</div>
<div class="col-sm-4 col-md-3">
<input type="text" name="quantity" class="form-control" value="1" />
</div>
<div class="col-sm-4 col-md-3">
<input type="submit" name="add_to_cart" class="btn btn-info" value="Add to Cart" />
</div>
</div> <!-- ./row -->
</div>
</form>
</div>
<?php
} // end while
echo '</div>';
} // end if
?>

How to display one image at a time?

I am currently implementing an upload the image function on my semester website project. However, the problem I am getting is when I upload an image and proceed to re-upload another image. the images stack on each other and when I refresh it doesn't remove all the images uploaded at all.
Image for Context:
<?php
include 'config.php';
session_start();
if (isset($_POST['submit'])) {
$email = $_POST['email'];
$name = $_POST['name'];
$rating = $_POST['rating'];
$contact = $_POST['contact'];
$category = $_POST['category'];
$feedback = $_POST['feedback'];
$sql = "INSERT INTO feedback(email,name,contact,category,feedback) VALUES('$email','$name','$contact','$category','$feedback')";
$result = mysqli_query($conn, $sql);
if ($result) {
header('location: feedback.php');
}
$sql2 = "INSERT INTO rate(rating) VALUES('$rating')";
$result = mysqli_query($conn,$sql2);
if($result){
header('location: feedback.php');
}
}
if(isset($_POST['upload'])){
$filename = $_FILES['uploadfile']['name'];
$tempname = $_FILES['uploadfile']['tmp_name'];
$folder = "./image/".$filename;
$sql3 = "INSERT INTO image(filename)VALUES('$filename')";
mysqli_query($conn,$sql3);
move_uploaded_file($tempname,$folder);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="feedbackphp.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/rateYo/2.3.2/jquery.rateyo.min.css">
</head>
<body>
<section class="contact">
<div class="container-lg">
<div class="text-center mt-5">
<h2>Feedback Form</h2>
<p class="lead">We Would like to hear your Feedback!</p>
</div>
<div class="row justify-content-center my-5">
<div class="col-lg-6">
<form action="" method="post" enctype="multipart/form-data">
<label for="email" class="form-label">Email Address</label>
<input type="email" name="email" class="form-control" id="email" placeholder="Enter your Email">
<label for="name" class="form-label mt-2">Name</label>
<input type="text" name="name" class="form-control" id="name" placeholder="Enter your Name">
<label for="contact" class="form-label mt-2">Contact</label>
<input type="text" name="contact" class="form-control" id="contact" placeholder="Enter your Contact">
<label for="subject" class="form-label mt-2">Category</label>
<select class="form-select" name="category" id="subject">
<option value="">Select One</option>
<option value="Club Maintainence & Equipment">Club Maintainence & Equipment </option>
<option value="Club Cleanliness">Club Cleanliness</option>
<option value="Membership Issues">Membership Issues</option>
<option value="General/Others">General/Others</option>
</select>
<label for="rating" class="form-label mt-2">Rate Us!</label>
<div class="rateyo" id="rating"
data-rateyo-rating="0"
data-rateyo-num-stars="5"
data-rateyo-score="3">
</div>
<span class="result">0</span>
<input type="hidden" name="rating">
<br>
<label for="query" class="form-label mt-2">Feedback Message </label>
<textarea id="query" name="feedback" class="form-control" style="height:140px" placeholder="Enter Feedback Message here..."></textarea>
<label class="form-label mt-2">Upload File</label>
<div class="form-group mt-2">
<input class="form-control" type="file" name="uploadfile">
</div>
<br>
<div class="form-group">
<button class="btn btn-primary" type="submit" name="upload">Upload</button>
</div>
<div id="display-image">
<?php
$query = "SELECT * FROM image";
$result = mysqli_query($conn,$query);
while($data = mysqli_fetch_assoc($result)){
?>
<img src="./image/<?php echo $data['filename'];?>">
<?php
}
?>
</div>
<div class="mb-4 text-center mt-2">
<button type="submit" name="submit" class="btn btn-primary">Submit Feedback</button>
</div>
</form>
</div>
</div>
</div>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rateYo/2.3.2/jquery.rateyo.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="fbphp.js" type="text/javascript"></script>
</body>
</html>
You are selecting all images
$query = "SELECT * FROM image LIMIT 1";
Use the query about to set a limit to 1;
then using this will prevent you from using the while loop
Hope this will help

how to pass parameter in php? empty values returned?

i want to pass parameter in action method because of i am not able to pass parameter in header.
<form name="mailinglist1" method="post" action="report1.php" >
in this form i am using download button to connect my report (html)
$st1= 3106530;
header('Location: report1.php?num='.$st1 );
full coding
<?php
include("config/config.php");
include("header.php");
if(isset($_POST['search'])){
$query1 = mysql_query("SELECT * from staff where staff_code=".$_POST['staff']);
$row = mysql_fetch_array($query1);
$query2=mysql_query("SELECT * from master_tab where
deo_code =".$_POST['staff']
);
$query3 =mysql_query("select * from staff_bankinfo where staff_code=".$_POST['staff']);
$row1 = mysql_fetch_array($query3);
}
else if(isset($_POST['contact']))
{
mysql_query("INSERT into staff_bankinfo (staff_code, bank_name,branch,ifsc,acno) values('$_POST[staf]', '$_POST[bank_name]','$_POST[branch]','$_POST[ifsc]','$_POST[acno]')") or die(mysql_error());
$msg= "Added";
}
else
{
//$sheet_no = 202565;
//header('Location: print_edit_mark_details.php?num='.$sheet_no);
header('Location: report1.php?num='.$_POST['staff']);
// echo "hai";
}
?>
<?php include("theme.php"); ?>
</div><!-- /.ace-settings-container -->
<form method="post" id="form_id" class="form-horizontal" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
<td align="center" colspan="6">
<select name="staff" required>
<option value="">Select Staff</option>
<?php
//dropdwon list based on query1
<?php } ?>
</select>
</td>
<!--2 input item from_date and to_date -->
<label for="mindate">From<span class="important"></span></label>
<td align="center">
<input type="date" name="mindate" id="login_id" placeholder="st date" value="<?php echo isset($_POST['mindate']) ? $_POST['mindate'] : '' ?>" required> </td>
<label for="maxdate">To<span class="important"></span></label>
<td align="center"><input type="date" name="maxdate" id="login_id" placeholder="end date" value="<?php echo isset($_POST['maxdate']) ? $_POST['maxdate'] : '' ?>" required> </td>
<td align="center"><input name="search" type="submit" id="search" value="Submit" class="last btn btn-info"/></td>
<br />
<br />
</form>
<form name="mailinglist1" method="post" action="report1.php" >
<div class="row">
<div class="col-xs-12">
<div class="table-header">
Staff Details
</div>
<br />
<div class="form-group">
<!-- input item 1 fetched result from query1 -->
</div>
<div class="form-group">
<!-- input item 2 fetched result from query1 -->
</div>
</div>
<div class="form-group">
<!-- input item 3 fetched result from query1 -->
</div>
<div class="form-group">
<!-- input item 4 fetched result from query1 -->
</div>
<div class="form-group">
<!-- input item 5 fetched result from query1 -->
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-xs-12">
<div class="table-header">
Bank Details
</div>
<br />
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1">Bank Name
<span class="important"></span></label>
<div class="col-sm-9">
<!-- input item 1 fetched result from query3 -->
</div>
<div class="form-group">
<!-- input item 2 fetched result from query3 -->
</div>
</div>
<div class="form-group">
<!-- input item 3 fetched result from query3 -->
</div>
</div>
<div class="form-group">
<!-- input item 4 fetched result from query3 -->
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-xs-12">
<div class="table-header">
listing
</div>
<!-- div.table-responsive -->
<!-- div.dataTables_borderWrap -->
<div>
<table id="dynamic-table" name="dynamic-table" class="table table-striped table-bordered table-hover">
<thead>
<!--table fetched values from query2 -->
</table>
</div>
</div>
</div>
</div><!-- /.page-content -->
</div>
</div>
<br/>
<div align="center">
<input name="contact" type="submit" id="contact" value="Update" style="padding:5px" class="sendButton" disabled />
<input name="download" type="submit" id="download" value="Download PDF" style="padding:5px" class="btn btn-danger" />
</div>
</label>
</div>
</form>
</div><!-- /.main-content -->
<div class="footer">
<!-- footer -->
</div>
</div><!-- /.main-container -->
pdf downloaded but not getting $_GET('num') in report1.php . how to know whether parameter is passed or not. i attached full coding of my page.
You send form via POST method, your data will be sent by post.
Either change $_GET by $_POST or change the form method to GET.
Please try the code below, which will help you get the value in PHP file.
<?php
include("config/config.php");
include("header.php");
if(isset($_POST['search'])){
$query1 = mysql_query("SELECT * from staff where staff_code=".$_POST['staff']);
$row = mysql_fetch_array($query1);
$query2=mysql_query("SELECT * from master_tab where
deo_code =".$_POST['staff']
);
$query3 =mysql_query("select * from staff_bankinfo where staff_code=".$_POST['staff']);
$row1 = mysql_fetch_array($query3);
}
else if(isset($_POST['contact']))
{
mysql_query("INSERT into staff_bankinfo (staff_code, bank_name,branch,ifsc,acno) values('$_POST[staf]', '$_POST[bank_name]','$_POST[branch]','$_POST[ifsc]','$_POST[acno]')") or die(mysql_error());
$msg= "Added";
}
else
{
if ( isset($_POST['download']) && !empty($_POST['download']) ) {
$staff_id = $_POST['staff_id'];
if ($staff_id) {
header('Location: report1.php?num='.$staff_id);
}
}
}
?>
<?php include("theme.php"); ?>
</div><!-- /.ace-settings-container -->
<form method="post" id="form_id" class="form-horizontal" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
<td align="center" colspan="6">
<select name="staff" required>
<option value="">Select Staff</option>
<?php
//dropdwon list based on query1
<?php } ?>
</select>
</td>
<!--2 input item from_date and to_date -->
<label for="mindate">From<span class="important"></span></label>
<td align="center">
<input type="date" name="mindate" id="login_id" placeholder="st date" value="<?php echo isset($_POST['mindate']) ? $_POST['mindate'] : '' ?>" required> </td>
<label for="maxdate">To<span class="important"></span></label>
<td align="center"><input type="date" name="maxdate" id="login_id" placeholder="end date" value="<?php echo isset($_POST['maxdate']) ? $_POST['maxdate'] : '' ?>" required> </td>
<td align="center"><input name="search" type="submit" id="search" value="Submit" class="last btn btn-info"/></td>
<br />
<br />
</form>
<form name="mailinglist1" method="post" action="report1.php" >
<div class="row">
<div class="col-xs-12">
<div class="table-header">
Staff Details
</div>
<br />
<div class="form-group">
<!-- input item 1 fetched result from query1 -->
</div>
<div class="form-group">
<!-- input item 2 fetched result from query1 -->
</div>
</div>
<div class="form-group">
<!-- input item 3 fetched result from query1 -->
</div>
<div class="form-group">
<!-- input item 4 fetched result from query1 -->
</div>
<div class="form-group">
<!-- input item 5 fetched result from query1 -->
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-xs-12">
<div class="table-header">
Bank Details
</div>
<br />
<div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1">Bank Name
<span class="important"></span></label>
<div class="col-sm-9">
<!-- input item 1 fetched result from query3 -->
</div>
<div class="form-group">
<!-- input item 2 fetched result from query3 -->
</div>
</div>
<div class="form-group">
<!-- input item 3 fetched result from query3 -->
</div>
</div>
<div class="form-group">
<!-- input item 4 fetched result from query3 -->
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-xs-12">
<div class="table-header">
listing
</div>
<!-- div.table-responsive -->
<!-- div.dataTables_borderWrap -->
<div>
<table id="dynamic-table" name="dynamic-table" class="table table-striped table-bordered table-hover">
<thead>
<!--table fetched values from query2 -->
</table>
</div>
</div>
</div>
</div><!-- /.page-content -->
</div>
</div>
<br/>
<div align="center">
<input name="contact" type="submit" id="contact" value="Update" style="padding:5px" class="sendButton" disabled />
<input name="download" type="submit" id="download" value="Download PDF" style="padding:5px" class="btn btn-danger" />
<input type="hidden" name="staff_id" value="<?php // staff id which you will get from search form ?>">
</div>
</label>
</div>
</form>
</div><!-- /.main-content -->
<div class="footer">
<!-- footer -->
</div>
</div><!-- /.main-container -->
Comment:
When clicking download button, staff id should be populated in hidden
field. Then only you will get staff id. So plz check value while
clicking download button by using print_r();

PHP Display single value from session array

I currently have a PHP form for our partners to register quotes. After the user log in they are brought to the beginning of the quote form. I would like the user's first name to display in the first form field automatically.
The user's session information includes an array of values; one of which is the firstName value. This is the value that I would like to display in the first field when the user logs in.
When I try to load the page I am getting an error instead of the user's first name.
This is the error I am getting:
Notice: Undefined index: user in C:\wamp64\www\quote_generator\quote_tool.php on line 77
Here is the updated page code:
<?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">
Logout
</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>
Update: I have a session page that shows me the information on the current session, and these are the results for the form I am talking about:
View Image
The screenshot clarified it.
You should be able to use
$session['user']['firstName']
As noted in the comments above though, you will want to migrate away from using eval, which has security implications.

PHP Radio Buttons forms example

So lets say i have the following example how can i get values from radio buttons and acctualy work with those values? You can see that i tried something but i can't find it how to make it work ..
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-ex-collapse"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand">My learning skills: A self-assessment questionnaire</a></div>
<div class="collapse navbar-collapse" id="navbar-ex-collapse">
<ul class="nav navbar-nav navbar-right"></ul>
</div>
</div>
</div>
<div class="section">
<div class="container">
<div class="row">
<div class="col-md-12">
<form role="form" method="post">
<div class="form-group"><label class="control-label" for="exampleInputEmail1">Nume:</label><input class="form-control input-lg" id="exampleInputEmail1" placeholder="Enter name" type="text"></div>
<div class="form-group"><label class="control-label" for="exampleInputEmail1">Email address:</label><input class="form-control input-lg" id="exampleInputEmail1" placeholder="Enter email" type="email"></div>
<div class="container">
<div class= "row">
<h4>Your gender: *</h4>
</div>
<div class="row">
<div class="radio">
<label><input type="radio" name="gender" value="female">F</label>
</div>
<div class="radio">
<label><input type="radio" name="gender" value="male">M</label>
</div>
<div class="radio">
<label><input type="radio" name="gender" value="other">Other</label>
</div>
</div>
</br>
<div class="row">
<div class="form-group"><label class="control-label" for="exampleInputEmail1">Your age: *</label><input class="form-control input-lg" id="exampleInputEmail1" placeholder="Enter age" type="text"></div>
</div>
<div class= "row">
<h2>That was it! Please, keep your scores saved and check that after refilling in this questionnaire, in 6-8 months from now on. Happy learning!</h2>
</div>
<div class= "row">
<button type="submit" name="submit" value="submit" class="btn btn-primary btn-lg">Send</button>
</div>
</div>
</form>
<?php $gender = $_POST['contact']; echo $gender; ?>
</div>
</div>
</div>
</div>
</body>
</html>
As example:
echo $gender;
and the results should be $female
<?php $gender = $_POST['contact']; echo $gender; ?>
Change this to
<?php $gender = $_POST['gender']; echo $gender; ?>.
Name of your radio control is gender not contact.

Categories