Getting User name to another data table - php

I have two data tables like users and questions for login page and information page
when login I redirect do information page and I enter data in it after submitting I want to get this login user name to that questions data table, pls help me
login page like below
<?php
session_start();
?>
<html>
<head lang="en">
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="bootstrap-3.2.0-dist\css\bootstrap.css">
<title>Login</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="login-panel panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">Sign In</h3>
</div>
<div class="panel-body">
<form role="form" method="post" action="login.php">
<fieldset>
<div class="form-group" >
<input class="form-control" placeholder="E-mail" name="email" type="email" autofocus>
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" name="pass" type="password" value="">
</div>
<input class="btn btn-lg btn-success btn-block" type="submit" value="login" name="login" >
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
include("db_conection.php");
if(isset($_POST['login']))
{
$user_email=$_POST['email'];
$user_pass=$_POST['pass'];
$check_user="select * from users WHERE user_email='$user_email'AND user_pass='$user_pass'";
$run=mysqli_query($dbcon,$check_user);
if(mysqli_num_rows($run))
{
echo "<script>window.open('welcome.php','_self')</script>";
$_SESSION['email']=$user_email;
}
else
{
echo "<script>alert('Email or password is incorrect!')</script>";
}
}
?>
inner data page
<?php
session_start();
if(!$_SESSION['email'])
{
header("Location: login.php");
}
if(isset($_POST['submit'])){
header("Location: feedback.php");
exit;
}
?>
<html>
<head>
<title>
Registration
</title>
</head>
<body>
<h1>Welcome</h1><br>
<?php
echo $_SESSION['email'];
?>
<form action="profile.php" method="post">
<input type='submit' name='submit' value='Give Us Your Feedback' class='register' />
</form>
<h1>Logout here </h1>
</body>
</html>
data page
<?php
session_start();
include("config.php");
if(isset($_POST['submit']))
{
$answer1=$_POST['answer1'];
$answer2=$_POST['answer2'];
$answer3=$_POST['answer3'];
$answer4=$_POST['answer4'];
$answer5=$_POST['answer5'];
$answer6=$_POST['answer6'];
$insert=mysqli_query($conn,"insert into question(ans1,ans2,ans3,ans4,ans5,ans6)values('$answer1','$answer2','$answer3','$answer4','$answer5','$answer6')");
if($insert==TRUE)
{
header("Location:thanks.html");
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Feedback Form</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css">
<META http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<h3>Feedback Form</h3>
<div class="container">
<div class="row">
<div class="col-md-8 well">
<form class="sky-form" name="answer" method="post">
<div class="panel panel-default">
<ul class="list-group">
<li class="list-group-item">
<div class="row toggle" id="dropdown-detail-1" data-toggle="detail-1">
<div class="col-xs-10">
How did you contact technical support?
</div>
<div class="col-xs-2"><i class="fa fa-chevron-down pull-right"></i></div>
</div>
<div id="detail-1">
<hr></hr>
<div class="container">
<div class="fluid-row">
<div class="radio">
<input type="radio" name="answer1" id="a1" value="In Person"><label for="a1">In Person </label> <br>
<input type="radio" name="answer1" id="a2" value="Over the Telephone"><label for="a2">Over the Telephone </label><br>
<input type="radio" name="answer1" id="a3" value="Via Email"><label for="a3">Via Email</label><br>
<input type="radio" name="answer1" id="a4" value="Via Internet Chat"><label for="a4">Via Internet Chat </label>
</div>
</div>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row toggle" id="dropdown-detail-2" data-toggle="detail-2">
<div class="col-xs-10">
Overall, how would you rate the process for getting your problem resolved?
</div>
<div class="col-xs-2"><i class="fa fa-chevron-down pull-right"></i></div>
</div>
<div id="detail-2">
<hr></hr>
<div class="container">
<div class="fluid-row">
<div class="radio">
<input type="radio" name="answer2" id="b1" value="Very Good"><label for="b1">Very Good </label> <br>
<input type="radio" name="answer2" id="b2" value="Good"><label for="b2">Good </label><br>
<input type="radio" name="answer2" id="b3" value="Average"><label for="b3">Average</label><br>
<input type="radio" name="answer2" id="b4" value="Poor"><label for="b4">Poor </label><br>
<input type="radio" name="answer2" id="b5" value="Very Poor"><label for="b5">Very Poor </label>
</div>
</div>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row toggle" id="dropdown-detail-3" data-toggle="detail-3">
<div class="col-xs-10">
About how long did you have to wait before speaking to a technical support representative?
</div>
<div class="col-xs-2"><i class="fa fa-chevron-down pull-right"></i></div>
</div>
<div id="detail-3">
<hr></hr>
<div class="container">
<div class="fluid-row">
<div class="radio">
<input type="radio" name="answer3" id="c1" value="I was taken care of immediately"><label for="c1">I was taken care of immediately </label> <br>
<input type="radio" name="answer3" id="c2" value="Within 10 minutes"><label for="c2">Within 10 minutes</label><br>
<input type="radio" name="answer3" id="c3" value="Between 10 to 30 minutes"><label for="c3">Between 10 to 30 minutes</label><br>
<input type="radio" name="answer3" id="c4" value="Between 30 minutes to an hour"><label for="c4">Between 30 minutes to an hour</label><br>
<input type="radio" name="answer3" id="c5" value="More than 1 hour"><label for="c5">More than 1 hour</label>
</div>
</div>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row toggle" id="dropdown-detail-4" data-toggle="detail-4">
<div class="col-xs-10">
About how long did you have to wait before your issue was resolved?
</div>
<div class="col-xs-2"><i class="fa fa-chevron-down pull-right"></i></div>
</div>
<div id="detail-4">
<hr></hr>
<div class="container">
<div class="fluid-row">
<div class="radio">
<input type="radio" name="answer4" id="d1" value="Within 2 hours"><label for="d1">Within 2 hours</label> <br>
<input type="radio" name="answer4" id="d2" value="Between 2 to 4 hours"><label for="d2">Between 2 to 4 hours</label><br>
<input type="radio" name="answer4" id="d3" value="Between 4 to 8 hours"><label for="d3">Between 4 to 8 hours</label><br>
<input type="radio" name="answer4" id="d4" value="Between 8 to 12 hours"><label for="d4">Between 8 to 12 hours</label><br>
<input type="radio" name="answer4" id="d5" value="More than 12 hours"><label for="d5">More than 12 hours</label>
</div>
</div>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row toggle" id="dropdown-detail-5" data-toggle="detail-5">
<div class="col-xs-10">
The Technical Support Representative was knowledgeable?
</div>
<div class="col-xs-2"><i class="fa fa-chevron-down pull-right"></i></div>
</div>
<div id="detail-5">
<hr></hr>
<div class="container">
<div class="fluid-row">
<div class="radio">
<input type="radio" name="answer5" id="e1" value="Strongly Agree"><label for="e1">Strongly Agree</label> <br>
<input type="radio" name="answer5" id="e2" value="Agree"><label for="e2">Agree</label><br>
<input type="radio" name="answer5" id="e3" value="Neutral"><label for="e3">Neutral</label><br>
<input type="radio" name="answer5" id="e4" value="Disagree"><label for="e4">Disagree</label><br>
<input type="radio" name="answer5" id="e5" value="Strongly Disagree"><label for="e5">Strongly Disagree</label>
</div>
</div>
</div>
</div>
</li>
<label for="title">Please share any additional comments about your experience or suggestions on how we can better improve our technical support services.</label>
<textarea class="form-control" rows="3" name="answer6" maxlength="250">
</textarea>
</ul>
<div id="my_centered_buttons">
<button type="submit" name="submit" value="submit">Submit</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>

When you login then I think you have to store user information in to session and you can get user information directly from session including username.

Related

How can I make text appear on another page in a form?

I am making a get started button on my website, where the person enters his email and then presses "get started". The text should then be transferred to my login page in the email field.
Here is my code for the button:
<form method="post" action="#" class="container 50%">
<div class="row uniform 50%">
<div class="8u 12u$(xsmall)"><input type="email" name="email" id="email" placeholder="Your Email Address" /></div>
<div class="4u$ 12u$(xsmall)"><input type="button" value="Get Started" class="fit special" onclick="location.href='loginsystem/loginpage.php';"></div>
</div>
</form>
And here is my code for the login page:
<?php
/* Main page with two forms: sign up and log in */
require 'db.php';
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Sign-Up/Login Form</title>
<?php include 'css/css.html'; ?>
</head>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['login'])) { //user logging in
require 'login.php';
}
elseif (isset($_POST['register'])) { //user registering
require 'register.php';
}
}
?>
<body style="background-color: #1c1d26">
<div class="form">
<ul class="tab-group">
<li class="tab">Sign Up</li>
<li class="tab active">Log In</li>
</ul>
<div class="tab-content">
<div id="login">
<h1>Welcome Back!</h1>
<form action="loginpage.php" method="post" autocomplete="off">
<div class="field-wrap">
<label>
Email Address<span class="req">*</span>
</label>
<input type="email" required autocomplete="off" name="email"/>
</div>
<div class="field-wrap">
<label>
Password<span class="req">*</span>
</label>
<input type="password" required autocomplete="off" name="password"/>
</div>
<p class="forgot">Forgot Password?</p>
<button class="button button-block" name="login" />Log In</button>
</form>
</div>
<div id="signup">
<h1>Sign Up for Free</h1>
<form action="loginpage.php" method="post" autocomplete="off">
<div class="top-row">
<div class="field-wrap">
<label>
First Name<span class="req">*</span>
</label>
<input type="text" required autocomplete="off" name='firstname' />
</div>
<div class="field-wrap">
<label>
Last Name<span class="req">*</span>
</label>
<input type="text"required autocomplete="off" name='lastname' />
</div>
</div>
<div class="field-wrap">
<label>
Email Address<span class="req">*</span>
</label>
<input type="email"required autocomplete="off" name='email' />
</div>
<div class="field-wrap">
<label>
Set A Password<span class="req">*</span>
</label>
<input type="password"required autocomplete="off" name='password'/>
</div>
<button type="submit" class="button button-block" name="register" />Register</button>
</form>
</div>
</div><!-- tab-content -->
</div> <!-- /form -->
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'> </script>
<script src="js/index.js"></script>
</body>
</html>
Thank you!
In your get started form set action="yourLoginPage.php"
<form method="post" action="yourLoginPage.php" class="container 50%">
In your login page
<input type="email" required autocomplete="off" name="email" value="<?php echo $_POST["email"]; ?>"/>

How to get the multiple images selected by the user in a form and display it in next page?

`
<?php
ob_start();
session_start();
include_once 'dbconnect.php';
$error = false;
if ( isset($_POST['cust-submit2']) ) {
$pass1 = trim($_POST['cust-acc-pwd']);
$pass1 = strip_tags($_POST['cust-acc-pwd']);
$pass1 = htmlspecialchars($_POST['cust-acc-pwd']);
$pass2 = trim($_POST['cust-confirm-pwd']);
$pass2 = strip_tags($_POST['cust-confirm-pwd']);
$pass2 = htmlspecialchars($_POST['cust-confirm-pwd']);
$_POST = $_SESSION;
$acc_no = $_POST['cust-acc-no'];
echo "<h1>$acc_no</h1>";
if(empty($pass1) || empty($pass2)){
$error = true;
$passError = "Please enter your password.";
echo $passError;
}else if( strlen($pass1) < 6) {
$error = true;
$passError = "Password must have atleast 6 characters.";
echo $passError;
}
if (!$error){
if($pass1 == $pass2){
// password encrypt using SHA256();
$newpass = hash('sha256', $pass1);
$query = "UPDATE users SET userPass = '$newpass' WHERE
Account_no='$acc_no'";
$res = mysql_query($query);
if($res){
$errTyp = "<h1>success</h1>";
$errMSG = "<h2>Successfully Password Changed</h2>";
echo $errTyp;
echo $errMSG;
unset($pass1);
unset($pass2);
}
else{
$errMSG = "<h1>Failure!Try again later..</h1>";
echo $errMSG;
}
}
else{
echo "Passwords do not match";
}
}
if(!empty($_POST['check_list'])) {
// Counting number of checked checkboxes.
$checked_count = count($_POST['check_list']);
echo "You have selected following ".$checked_count." option(s): <br/>";
// Loop to store and display values of individual checked checkbox.
foreach($_POST['check_list'] as $selected) {
echo "<p>".$selected ."</p>";
}
}
else{
echo "<b>Please Select Atleast One Option.</b>";
}
}
$_POST = $_SESSION;
?>
<html>
<head>
<title>Online Bank</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">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
<link rel="stylesheet" href="banking.css">
<script src="banking.js"></script>
</head>
<body>
<div class="container">
<h1 class="float-left">Online Bank</h1>
<h1 class="float-right">Online Bank</h1>
<br>
<br>
<br>
<hr>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Home</a>
</div>
<ul class="nav navbar-nav">
<li class="active">Register</li>
<li>Products</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
</nav>
<br>
<div class="col-md-12">
<form method="post" action="">
Welcome <?php if(!empty($_POST['cust-acc-no'])) echo $_POST['cust-
acc-no'] ; ?>
<div class="col-md-4">
<h3 class="text-center">Customer Panel</h3>
<br>
<!-- <form method="post" action="">
Welcome <?php if(!empty($_POST['cust-acc-no']))
echo $_POST['cust-acc-no'] ; ?> -->
<div class="form-group">
<label for="cust-acc-pwd">Enter your New
Password</label>
<input type="text" class="form-control" name="cust-acc-
pwd" id="cust-acc-pwd">
</div>
<div class="form-group">
<label for="cust-confirm-pwd">Confirm your New Password:
</label>
<input type="password" class="form-control" name="cust-
confirm-pwd" id="cust-confirm-pwd">
</div>
<label for="usr">Select your Security Image: </label>
<br><br>
<button type="submit" class="btn btn-default btn-primary"
name="cust-submit2"><a class="a-btn">Submit</a></button>
<!-- </form> -->
</div>
<div class="col-md-8 d3 mt0">
<h3 class="text-center pb20 mt0">Select Upto 4 Random
Images</h3>
<div class="d3-2">
<div class="d4">
<div class="d5">
<div class="col-md-12">
<div class="col-md-4"><img
src="reg_images/01.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="01.jpg" id="img1"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/02.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="02.jpg" id="img2"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/03.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="03.jpg" id="img3"></label>
</div>
</div>
</div>
<div class="col-md-12 mt10">
<div class="col-md-4"><img
src="reg_images/04.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="04.jpg" id="img4"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/05.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="05.jpg" id="img5"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/06.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="06.jpg" id="img6"></label>
</div>
</div>
</div>
<div class="col-md-12 mt10">
<div class="col-md-4"><img
src="reg_images/07.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="07.jpg" id="img7"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/08.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="08.jpg" id="img8"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/09.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="09.jpg" id="img9"></label>
</div>
</div>
</div>
<div class="col-md-12 mt10">
<div class="col-md-4"><img
src="reg_images/10.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="10.jpg" id="img10"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/11.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="11.jpg" id="img11"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/12.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="12.jpg" id="img12"></label>
</div>
</div>
</div>
<div class="col-md-12 mt10">
<div class="col-md-4"><img
src="reg_images/13.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="13.jpg" id="img13"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/14.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="14.jpg" id="img14"></label>
</div>
</div>
<div class="col-md-4"><img
src="reg_images/15.jpg" class="reg-img">
<div class="checkbox">
<label><input type="checkbox"
name="check_list[]" value="15.jpg" id="img15"></label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</body>
<html>
`I have created a register page(signup2.php) where user is asked to choose the 4 security images for him., along with other details.
Then when the user log-in, out of the 4 images chosen by him I want to display one of the images out of the 4 randomly along with some other random images and the user should only be able to login if he selects the right image.
Also it is must for the user to select the 4 images else he should not be able to register.
How can I do this? I am developing the website using PHP with MySql.
Any quick help would be greatly appreciated!
To solve this you can use a hidden textbox. On the 4 images you add a onclick event that will update the value of the hidden textbox. So when the form is submited the textbox will be sent with the form, just check that textbox and see if it has the value you expect.
The code below is a example you should add more to make the image marked in someway to make the user understand that it is marked to but i leave that part for you.
<div>
<input id="securityImage" type="hidden" value="" />
<img src="1.png" onlick="$("#securityImage").val("1");" />
<img src="2.png" onlick="$("#securityImage").val("2");" />
<img src="3.png" onlick="$("#securityImage").val("3");" />
<img src="4.png" onlick="$("#securityImage").val("4");" />
</div>

page-header and row alignment

Picture of the issue.
I'm learning how to display mysql database data with php and running into a slight issue with alignment. The page-header of this site doesn't align with the first row of products. Here's the code:
<div class="container">
<div class="page-header">
<h1>For Sale</h1>
</div>
<div class="products">
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4">
<li class="product thumbnail">
<form method="post" action="cart_update.php">
<div class="product-content">
<div class="product-thumb"><img src="{$obj->product_img_name}" style="width:100%"></div>
<div class="caption">
<h3>{$obj->product_name}</h3>
<div class="product-desc"><p>{$obj->product_desc}</p></div>
<div class="product-info">
Price: {$currency}{$obj->price}
</div>
<fieldset>
<label>
<span>Color</span>
<select name="product_color">
<option value="Black">Black</option>
<option value="Silver">Silver</option>
</select>
</label>
<label>
<span>Quantity</span>
<input type="text" size="2" maxlength="2" name="product_qty" value="1" />
</label>
</fieldset>
<input type="hidden" name="product_code" value="{$obj->product_code}" />
<input type="hidden" name="type" value="add" />
<input type="hidden" name="return_url" value="{$current_url}" />
<div align="left"><button type="submit" class="add_to_cart btn btn-primary">Add</button></div>
</div></div>
</form>
</li>
</div>
Since you're using bootstrap, wrapping the <h1> tag with a <div class="container"> will horizontally align the title with your product items.
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="page-header">
<div class="container">
<h1>For Sale</h1>
</div>
</div>
<div class="products">
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4">
<li class="product thumbnail">
<form method="post" action="cart_update.php">
<div class="product-content">
<div class="product-thumb"><img src="https://placehold.it/350x150" style="width:100%"></div>
<div class="caption">
<h3>name</h3>
<div class="product-desc">
<p>description</p>
</div>
<div class="product-info">
Price: $ 10,50
</div>
<fieldset>
<label>
<span>Color</span>
<select name="product_color">
<option value="Black">Black</option>
<option value="Silver">Silver</option>
</select>
</label>
<label>
<span>Quantity</span>
<input type="text" size="2" maxlength="2" name="product_qty" value="1" />
</label>
</fieldset>
<input type="hidden" name="product_code" value="{$obj->product_code}" />
<input type="hidden" name="type" value="add" />
<input type="hidden" name="return_url" value="{$current_url}" />
<div align="left">
<button type="submit" class="add_to_cart btn btn-primary">Add</button>
</div>
</div>
</div>
</form>
</li>
</div>

Custom Signup Form Using Mailchimp - Connection could not be established with host mail.yourdomain.com [Operation timed out #60]

I am trying to have a custom form on my website. The form gathers diet preferences, and upon submit, I'd like to grab that information with their name and email, and add it to a list in Mailchimp. I have setup the list correctly in Mailchimp, and the form is built and styled on my page. I followed the following article, as you can see in my code, based on Mailchimp's recommendation on creating a custom form.
http://kb.mailchimp.com/lists/signup-forms/host-your-own-signup-forms
I think I have connected each input to it's corresponding element in the Mailchimp list, but when I hit the submit button, nothing happens for about 20 seconds and then I get the following error:
Connection could not be established with host mail.yourdomain.com [Operation timed out #60]
I am currently developing on a local server using MAMP - and feel this may be an issue, but if not what can I do to make this custom form work properly?
<form action="https://platesite.us14.list-manage.com/subscribe/post" method="POST" class="text-center form-email">
<input type="hidden" name="u" value="694035325d6c49e6922fda852">
<input type="hidden" name="id" value="e9b40e5d0e">
<h4 class="uppercase mt48 mt-xs-0">Tell Us about yourself</h4>
<p class="lead mb64 mb-xs-24">
Share a little bit about your taste preferences <br>
so we can create a plan just for you.
</p>
<div class="overflow-hidden">
<hr>
<h6 class="uppercase">
1. What is your plan preference?
</h6>
<div class="col-sm-3">
<p class="mb16">
Simply Healthy
</p>
<div class="checkbox-option text-left">
<div class="inner"></div>
<input type="radio" name="MERGE3" value="Simply Healthy" />
</div>
</div>
<div class="col-sm-3">
<p class="mb16">
Paleo
</p>
<div class="checkbox-option text-left">
<div class="inner"></div>
<input type="radio" name="MERGE3" value="Paleo" />
</div>
</div>
<div class="col-sm-3">
<p class="mb16">
Vegetarian
</p>
<div class="checkbox-option text-left">
<div class="inner"></div>
<input type="radio" name="MERGE3" value="Vegetarian" />
</div>
</div>
<div class="col-sm-3">
<p class="mb16">
Gluten-Free
</p>
<div class="checkbox-option text-left">
<div class="inner"></div>
<input type="radio" name="MERGE3" value="Gluten-Free" />
</div>
</div>
<hr>
</div>
<div class="overflow-hidden">
<div class="col-sm-6 col-sm-offset-3">
<h6 class="uppercase">
2. How many people are you cooking for?
</h6>
<div class="select-option">
<i class="ti-angle-down"></i>
<select name="MERGE4">
<option selected value="Default">Select An Option</option>
<option value="google">1</option>
<option value="website">2</option>
<option value="friend">3</option>
<option value="friend">4</option>
<option value="friend">5</option>
<option value="other">6</option>
</select>
</div>
</div>
<hr>
</div>
<div class="overflow-hidden">
<h6 class="uppercase">
3. How long do you typically have to prepare meals?
</h6>
<div class="col-sm-3">
<p>
Less than 20 min. </p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE5" value="less than 20" />
</div>
</div>
<div class="col-sm-3">
<p>20 - 35 min.</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE5" value="20-35" />
</div>
</div>
<div class="col-sm-3">
<p>35 - 60 min.</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE5" value="35-60" />
</div>
</div>
<div class="col-sm-3">
<p>60+ min.</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE5" value="60+" />
</div>
</div>
<hr>
</div>
<div class="overflow-hidden">
<h6 class="uppercase">
3. How adventurous are you with cooking?
</h6>
<div class="col-sm-4">
<p>
I like simple food, thanks </p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE6" value="I like simple food, thanks" />
</div>
</div>
<div class="col-sm-4">
<p>I'll try it if it sounds good</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE6" value="I'll try it if it sounds good" />
</div>
</div>
<div class="col-sm-4">
<p>I'll try anything!</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE6" value="I'll try anything!" />
</div>
</div>
<hr>
</div>
<div class="overflow-hidden">
<h6 class="uppercase">
4. What ingredients would you like to avoid?
</h6>
<div class="col-sm-2">
<p>All Dairy</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="All Dairy" />
</div>
</div>
<div class="col-sm-2">
<p>Cheese</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Cheese" />
</div>
</div>
<div class="col-sm-2">
<p>Eggs</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Eggs" />
</div>
</div>
<div class="col-sm-2">
<p>Tree Nuts</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Tree Nuts" />
</div>
</div>
<div class="col-sm-2">
<p>Peanuts</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Peanuts" />
</div>
</div>
<div class="col-sm-2">
<p>Soy</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Soy" />
</div>
</div>
<div class="col-sm-2">
<p>Tofu</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Tofu" />
</div>
</div>
<div class="col-sm-2">
<p>Beef</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Beef" />
</div>
</div>
<div class="col-sm-2">
<p>Chicken</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Chicken" />
</div>
</div>
<div class="col-sm-2">
<p>Pork</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Pork" />
</div>
</div>
<div class="col-sm-2">
<p>Lamb</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Lamb" />
</div>
</div>
<div class="col-sm-2">
<p>Fish</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Fish" />
</div>
</div>
<div class="col-sm-2">
<p>Shellfish</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Shellfish" />
</div>
</div>
<div class="col-sm-2">
<p>Avocado</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Avocado" />
</div>
</div>
<div class="col-sm-2">
<p>Cilantro</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Cilantro" />
</div>
</div>
<div class="col-sm-2">
<p>Bell Pepper</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Bell Pepper" />
</div>
</div>
<div class="col-sm-2">
<p>Mushroom</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Mushroom" />
</div>
</div>
<div class="col-sm-2">
<p>Spicy Food</p>
<div class="radio-option">
<div class="inner"></div>
<input type="radio" name="MERGE7" value="Spicy Food" />
</div>
</div>
<div class="col-sm-8 col-sm-offset-2">
<div class="inner"></div>
<input type="text" name="MERGE8" class="col-md-12 " placeholder="Other (list separated by comma)" />
</div>
<hr>
</div>
<div class="overflow-hidden">
<h6 class="uppercase">
3. Your Account Details
</h6>
<input type="text" name="MERGE1" class="col-md-6 validate-required" placeholder="First Name*" />
<input type="text" name="MERGE2" class="col-md-6 validate-required" placeholder="Last Name*" />
<input type="text" name="MERGE0" class="col-md-12 validate-required validate-email" placeholder="Your Email Address*" />
<hr>
</div>
<div class="overflow-hidden">
<div class="col-sm-6 col-sm-offset-3">
<h6 class="uppercase">
4. Lastly, how did you hear of us?
</h6>
<div class="select-option">
<i class="ti-angle-down"></i>
<select name="MERGE9">
<option selected value="Default">Select An Option</option>
<option value="google">Google</option>
<option value="website">Facebook</option>
<option value="friend">Instagram</option>
<option value="friend">Friend Referral</option>
<option value="friend">Influencer Referral</option>
<option value="friend">Blog</option>
<option value="other">Other</option>
</select>
</div>
<input type="submit" class="button" name="submit" value="Subscribe to list">
<input type="hidden" name="ht" value="b750d7603dc70714c655f39211d647bec3bed54f:MTQ4MDQ4Nzc0OS44NTIx">
<input type="hidden" name="mc_signupsource" value="hosted">
</div>
</div>
</form>

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