I'm trying to solve an weird issue for a school group project on my own, but I'm at wit's end. Essentially, I have a Bootstrap 4 Carousel with three images. Though one of the images is displayed, you can't advance to the next or previous slides. The initial webpage is launched using php as follows:
<?php
//require_once('connection.php');
if (isset($_GET['controller']) && isset($_GET['action'])) {
$controller = $_GET['controller'];
$action = $_GET['action'];
} else {
$controller = 'static';
$action = 'landing';
}
require_once('views/layout.php');
?>
The landing page launches layout.php (which has the Bootstrap, jQuery, popper and other JavaScript files and landing.php (which has the carousel code:
landing.php:
<div id="main_container" class="container-fluid">
<div id="body" class="container">
<p>Stuff about how great the application is.</p>
<div id="carousel" class="carousel slide" content="width=device-width data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0" class="active"></li>
<li data-target="#carousel" data-slide-to="1"></li>
<li data-target="#carousel" data-slide-to="2"></li>
</ol>
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="./views/images/kids_kites.png" alt="Los Angeles">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<p>We had such a great time in LA!</p>
</div>
</div>
<div class="carousel-item">
<img src="./views/images/kids_playing.png" alt="Chicago">
<div class="carousel-caption">
<h3>Chicago</h3>
<p>We had such great pizza in CHI!</p>
</div>
</div>
<div class="carousel-item">
<img src="./views/images/kids_swing.png" alt="New York">
<div class="carousel-caption">
<h3>New York</h3>
<p>It is too crowded!</p>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#carousel" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#carousel" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</div>
Search Events
</div>
layout.php
<!doctype HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<script defer src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script defer src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"
integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<title>Kamps For Kids</title>
<link rel="stylesheet" href="views/styles/styles.css">
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script defer src="views/scripts/main.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
</head>
<body>
<?php
require_once "templates/header.php";
require_once "templates/footer.php";
require_once "routes.php";
?>
<div id="id01" class="modal">
<!--action_page.php is the php file which will perform user validation when the 'submit' button is clicked -->
<form class="modal-content animate" action="/action_page.php">
<div class="img-container">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
<div><img src="./views/images/KamparoosLogo.png" alt="Logo" class="logo"></div>
<img src="./views/images/img_avatar2.png" alt="Avatar" class="avatar">
<div>
<!-- Add icon library from font-awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Add font awesome icons -->
</div>
</div>
<div class="container">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="user-name" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
</div>
<div class="container" style="background-color:#FAFC2F">
<button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancel-btn">
Cancel
</button>
<span class="psw">Forgot password?</span>
</div>
</form>
</div>
<div id="id02" class="modal">
<!--action_page.php is the php file which will perform user validation when the 'submit' button is clicked -->
<form class="modal-content animate" name="registrationForm" onsubmit="return validateForm()" method="post"
action="/action_page.php">
<div class="img-container">
<h3>Registration Form</h3>
<span onclick="document.getElementById('id02').style.display='none'" class="close" title="Close Modal">×</span>
<div><img src="./views/images/KamparoosLogo.png" alt="Logo" class="logo"></div>
<img src="./views/images/img_avatar2.png" alt="Avatar" class="avatar">
<div>
<!-- Add icon library from font-awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</div>
</div>
<div class="container">
<div class="form-row">
<div class="form-group col-md-6">
<label for="firstName">First Name</label>
<input type="text" class="form-control" id="firstName" placeholder="Enter first name" name="firstName"
required>
</div>
<div class="form-group col-md-6">
<label for="lastName">Last Name</label>
<input type="text" class="form-control" id="lastName" placeholder="Enter last name" name="lastName"
required>
</div>
<div class="form-group col-md-6">
<label for="emailAddress">Email Address</label>
<input type="email" class="form-control" id="emailAddress" placeholder="Enter email address"
name="emailAddress" required>
</div>
<div class="form-group col-md-6">
<label for="phoneNumber">Phone Number</label>
<input type="tel" class="form-control" id="phoneNumber" placeholder="Enter 10 digit phone number"
name="phoneNumber" required
pattern="[0-9]{3}[0-9]{3}[0-9]{4}"
size="10">
</div>
<div class="form-group col-md-12">
<label for="numOfKids">Number of Kids </label>
<select name="numOfKids" id="numOfKids">
<option value="">Select...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<div class="form-group col-md-4">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" placeholder="Enter password" name="password"
required>
</div>
<div class="form-group col-md-4">
<label for="confirmPassword">Confirm Password</label>
<input type="password" class="form-control" id="confirmPassword" placeholder="Re-enter password"
name="confirmPassword" required>
</div>
<div class="form-group col-md-12">
<label for="userRole">Register as </label>
<select name="userRole" id="userRole" required>
<option value="">Select...</option>
<option value="user">Individual User</option>
<option value="admin">Admin</option>
<option value="organization">Organization</option>
</select>
</div>
</div>
</div>
<button type="submit" class="btn btn-danger btn-success"
">Register</button>
</form>
</div>
<script>
// Get the modal
var modal = document.getElementById('id01');
// When the user clicks anywhere outside of the modal, the modal with close
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
// Get the modal
var modalTwo = document.getElementById('id02');
// When the user clicks anywhere outside of the modal, the modal with close
window.onclick = function (event) {
if (event.target == modalTwo) {
modal.style.display = "none";
}
}
</script>
</body>
</html>
If you're interested, the project is being saved in a GitHub repository at : https://github.com/ad410project/ad410project I'm sure it's possible some crazy php issue, but any help or suggestions would be appreciated.
Related
This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 5 years ago.
I tried the other solutions on this and other sites, but can´t make it work.
When I press refresh empty data is sent to phpmyadmin, and a blank entry is made.
When I press submit it doesn´t send anything, not even blank.
My database connection is working.
conn
<?php
$host = 'localhost'; // min host.
$user = 'root'; // mit brugernavn.
$password = 'mysql'; // mit password. Er tomt for Windows-brugere, men root for Mac-brugere.
$database = 'boliger'; // navnet på min database.
$conn = new mysqli($host, $user, $password, $database);
mysqli_set_charset($conn, 'utf8');
if ($conn->connect_error)
die($conn->connect_error);
?>
index
<?php
include_once 'conn.php';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<link rel="apple-touch-icon" sizes="76x76" href="assets/img/apple-icon.png" />
<link rel="icon" type="image/png" href="assets/img/favicon.png" />
<title>Bolig</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />
<!-- CSS Files -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
<link href="assets/css/paper-bootstrap-wizard.css" rel="stylesheet" />
<!-- CSS Just for demo purpose, don't include it in your project -->
<link href="assets/css/demo.css" rel="stylesheet" />
<!-- Fonts and Icons -->
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Muli:400,300' rel='stylesheet' type='text/css'>
<link href="assets/css/themify-icons.css" rel="stylesheet">
</head>
<body>
<div class="image-container set-full-height" style="background-image:">
<!-- Creative Tim Branding -->
<!-- Big container -->
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<!-- Wizard container -->
<div class="wizard-container">
<div class="card wizard-card" data-color="green" id="wizard">
<form method="POST" action="process.php">
<!-- You can switch " data-color="green" " with one of the next bright colors: "blue", "azure", "orange", "red" -->
<div class="wizard-header">
<h3 class="wizard-title">Søg bolig</h3>
<p class="category">Denne information vil hjælpe os med, at denne et billed af dine bolig ønsker.</p>
</div>
<div class="wizard-navigation">
<div class="progress-with-circle">
<div class="progress-bar" role="progressbar" aria-valuenow="1" aria-valuemin="1" aria-valuemax="4" style="width: 15%;"></div>
</div>
<ul>
<li>
<a href="#location" data-toggle="tab">
<div class="icon-circle">
<i class="ti-map"></i>
</div>
Placering
</a>
</li>
<!--
<li>
<a href="#type" data-toggle="tab">
<div class="icon-circle">
<i class="ti-direction-alt"></i>
</div>
Type
</a>
</li>
-->
<li>
<a href="#facilities" data-toggle="tab">
<div class="icon-circle">
<i class="ti-panel"></i>
</div>
Kontakt Oplysninger
</a>
</li>
</ul>
</div>
<div class="tab-content">
<div class="tab-pane" id="location">
<div class="row">
<div class="col-sm-12">
<h5 class="info-text"> Lade os starte med, at få de grundlæggende oplysninger.</h5>
</div>
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Kommune 1</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
</div>
<div class="form-group">
<label>Kommune 2</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
</div>
<div class="form-group">
<label>Kommune 3</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
</div>
<div class="form-group">
<label>Kommune 4</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
</div>
<div class="form-group">
<label>Kommune 5</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Antal Voksne</label>
<select class="form-control">
<option disabled="" selected="">- Voksne -</option>
<option>1 Person</option>
<option>2 Personer </option>
<option>3 Personer</option>
<option>4 Personer</option>
<option>5 Personer</option>
<option>6+ Personer</option>
</select>
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Antal Børn</label>
<select class="form-control">
<option disabled="" selected="">- Børn -</option>
<option>1 Barn</option>
<option>2 Børn </option>
<option>3 Børn</option>
<option>4 Børn</option>
<option>5 Børn</option>
<option>6+ Børn</option>
</select>
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Antal Rum</label>
<select class="form-control">
<option disabled="" selected="">- Værelser -</option>
<option>1 Værelse</option>
<option>2 Værelser </option>
<option>3 Værelser</option>
<option>4 Værelser</option>
<option>5 Værelser</option>
<option>6+ Værelser</option>
</select>
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Maksimum husleje inkl. forbrug</label>
<div class="input-group">
<input type="text" class="form-control" placeholder="Husleje">
<span class="input-group-addon">DKK</span>
</div>
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Kæledyr</label>
<div class="checkbox">
<label><input type="checkbox" value="">Hvis du har kæledyr og ønsker, at det er tilladt i den nye bolig, så sæt venligst et flueben.</label>
</div>
</div>
</div>
</div>
</div>
<!--
<div class="tab-pane" id="type">
<h5 class="info-text">Hvilken form for bolig har du?</h5>
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<div class="col-sm-4 col-sm-offset-2">
<div class="choice" data-toggle="wizard-checkbox">
<input type="checkbox" name="jobb" value="Design">
<div class="card card-checkboxes card-hover-effect">
<i class="ti-home"></i>
<p>Lejlighed</p>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="choice" data-toggle="wizard-checkbox">
<input type="checkbox" name="jobb" value="Design">
<div class="card card-checkboxes card-hover-effect">
<i class="ti-package"></i>
<p>Der komme flere på, i takt med, at vi udvider.</p>
</div>
</div>
</div>
</div>
</div>
</div>
-->
<div class="tab-pane" id="facilities">
<div class="row">
<div class="col-sm-12">
<h5 class="info-text">Dine kontaktoplysninger</h5>
</div>
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Navn</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast navn">
</div>
</div>
<div class="col-sm-5 col-sm-offset">
<div class="form-group">
<label>Email</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast email">
</div>
</div>
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Mobil nummer</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast mobil nummer">
</div>
</div>
</div>
</div>
<div class="wizard-footer">
<div class="pull-right">
<input type='button' class='btn btn-next btn-fill btn-success btn-wd' name='next' value='Næste' />
<input type='submit' class='btn btn-finish btn-fill btn-success btn-wd' name="submit" value="Submit" />
</div>
<div class="pull-left">
<input type='button' class='btn btn-previous btn-default btn-wd' name='previous' value='Tilbage' />
</div>
<div class="clearfix"></div>
</div>
</form>
</div>
</div> <!-- wizard container -->
</div>
</div> <!-- row -->
</div> <!-- big container -->
<div class="footer">
<div class="container text-center">
</div>
</div>
</div>
<?php
if( isset( $_POST['submit'] ) )
{
$hvemErDu = $_POST['hvemErDu'];
} else {
echo error;
}
//connecting to sql database
$conn or die( $conn->error );
//inserting details into table
$insert = $conn->query( "INSERT INTO lejere ( `hvemErDu` ) VALUE ( '$hvemErDu' )" );
//closing mysqli connection
$mysqli->close;
//if ($_POST) {
// if (isset($_POST["Submit"])) {
// // $hvemErDu = $_POST["hvemErDu"];
// // Se side 250
// mysqli_query($conn, "INSERT INTO lejere (hvemErDu)
//VALUES ('$_POST[hvemErDu]')";
//
?>
</body>
<!-- Core JS Files -->
<script src="assets/js/jquery-2.2.4.min.js" type="text/javascript"></script>
<script src="assets/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/js/jquery.bootstrap.wizard.js" type="text/javascript"></script>
<!-- Plugin for the Wizard -->
<script src="assets/js/paper-bootstrap-wizard.js" type="text/javascript"></script>
<!-- More information about jquery.validate here: http://jqueryvalidation.org/ -->
<script src="assets/js/jquery.validate.min.js" type="text/javascript"></script>
</html>
process
<?php
//process.php
if ($_SERVER["REQUEST_METHOD"] == "POST") {//Check it is coming from a form
$u_name = $_POST["hvemErDu"]; //set PHP variables like this so we can use them anywhere in code below
//$u_email = $_POST["user_email"];
//$u_text = $_POST["user_text"];
//print output text
print "Hello " . $u_name . "!, we have received your message and email "; //.$u_email;
print "We will contact you very soon!";
}
?>
How does your form look like? Do you have a "submit" input at all?
From what I see in your code, SQL statement runs every time you send the form, without any condition, you better place the query inside the condition brackets, like:
<?php
if (isset( $_POST['submit'] ))
{
$hvemErDu = $_POST['hvemErDu'];
//connecting to sql database
$conn or die( $conn->error );
//inserting details into table
$insert = $conn->query("INSERT INTO lejere ( `hvemErDu` ) VALUE ( '$hvemErDu' )");
//closing mysqli connection
$mysqli->close;
} else
{
echo 'error';
}
?>
Pay attention that you also echo error - I'm not sure if you meant to echo the string 'error' or the variable $error.
But again, this time it looks like you won't have any record - not even a blank one, can you show the whole form code?
Update:
As for your code, pay attention that when you post your form, you submit it to process.php, is that file exists at all? as your code wouldn't work unless you submit the form to the same page, as the following code:
// Send the form to the same page - index.php
<form method="POST">
Update:
You've another problem, you've many inputs which share the same name: hvemErDu.
You've to give each input a unique name, otherwise the latest input's value is gonna be submitted to server.
This is from your index.php code:
<label>Kommune 1</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Kommune du gerne vil have bolig i?">
<label>Navn</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast navn">
<label>Email</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast email">
<label>Mobil nummer</label>
<input type="text" name="hvemErDu" class="form-control" id="exampleInputEmail1" placeholder="Indtast mobil nummer">
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.
Iam creating a page. The sign up works fine and takes me to home page but after logging out and trying to login again. The login button redirects me back to the registration page.
Please Help! I have checked through over and over and cant find any error.
login.php
<?php
if(isset($_POST['Login']))
{error_reporting(1);
$connection = mysqli_connect('localhost','root','','uni-saga');
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$user=$_POST['username'];
$pass=$_POST['password'];
$que1=mysqli_query($connection,"select * from users where Email='$user' and Password='$pass'");
$count1=mysqli_num_rows($que1);
if($count1>0)
{
session_start();
$_SESSION['tempsagauser']=$user;
$que6=mysqli_query("select * from users where Email='$user'");
$rec6=mysqli_fetch_array($que6);
$userid=$rec6[0];
$que2=mysqli_query($connection,"select * from user_profile_pic where user_id=$userid");
$count2=mysqli_num_rows($que2);
if($count2>0)
{
$que3=mysqli_query($connection,"select * from user_secret_quotes where user_id=$userid");
$count3=mysqli_num_rows($que3);
if($count3>0)
{
$que4=mysqli_query($connection,"select * from user_secret_quotes where user_id=$userid");
while($rec=mysqli_fetch_array($que4))
{
$que2=$rec[3];
$ans2=$rec[4];
}
if($que2=="" && $ans2=="")
{
header("location:saga_files/saga_step/saga_step3/Secret_Question2.php");
}
else
{
session_start();
$_SESSION['sagauser']=$user;
$query1=mysqli_query($connection,"select * from users where Email=$user");
$rec1=mysqli_fetch_array($query1);
$userid=$rec1[0];
mysqli_query($connection,"update user_status set status='Online' where user_id='$userid'");
header("location:saga_files/saga_home/Home.php");
}
}
else
{
header("location:saga_files/saga_step/saga_step2/Secret_Question1.php");
}
}
else
{
while($rec=mysqli_fetch_array($que1))
{
$Gender=$rec[4];
}
if($Gender=="Male")
{
header("location:saga_files/saga_step/saga_step1/Step1_Male.php");
}
else
{
header("location:saga_files/saga_step/saga_step1/Step1_Female.php");
}
}
}
else
{
$que5=mysqli_query($connection,"select * from users where Email='$user'");
$count5=mysqli_num_rows($que5);
if($count5>0)
{
header("location:Invalid_Password.php");
}
else
{
header("location:Invalid_Username.php");
}
}
}
?>
index.php
<?php
include("Login.php");
include("saga_files/saga_index_file/saga_SignUp_file/SignUp.php");
?>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>UniSaga</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/ionicons.min.css" />
<link rel="stylesheet" href="css/font-awesome.min.css" />
<!--Google Font-->
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,400i,700,700i" rel="stylesheet">
<!--Favicon-->
<link rel="shortcut icon" type="image/png" href="images/fav.png"/>
</head>
<script>
function time_get()
{
d = new Date();
mon = d.getMonth()+1;
time = d.getDate()+"-"+mon+"-"+d.getFullYear()+" "+d.getHours()+":"+d.getMinutes();
}
</script>
<header id="header-inverse">
<nav class="navbar navbar-default navbar-fixed-top menu">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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" href="index-register.html"><img src="images/logo.png" alt="logo" /></a>
</div>
</div>
</nav>
</header>
<div id="lp-register">
<div class="container wrapper">
<div class="row">
<div class="col-sm-5">
<div class="intro-texts">
<h1 class="text-white">UniSaga</h1>
<p>Connect With Students from other Your University and Other Universities and get the latest news on what is Happening Around these learning Institutions. <br /> <br />What Are You Waiting For. Join Now And Experience It Like Never Before.</p>
</div>
</div>
<div class="col-sm-6 col-sm-offset-1">
<div class="reg-form-container">
<div class="reg-options">
<ul class="nav nav-tabs">
<li class="active">Register</li>
<li>Login</li>
</ul><!--Tabs End-->
</div>
<!--Registration Form Contents-->
<div class="tab-content">
<div class="tab-pane active" id="register">
<h3>Register Now !!!</h3>
<p class="text-muted">Its Free and Always Will Be.</p>
<!--Register Form-->
<form method="post" name="registration_form" id='registration_form' class="form-inline">
<div class="row">
<div class="form-group col-xs-6">
<label for="first_name" class="sr-only">First Name</label>
<input id="first_name" class="form-control input-group-lg" type="text" name="first_name" title="Enter first name" placeholder="First name"/>
</div>
<div class="form-group col-xs-6">
<label for="last_name" class="sr-only">Last Name</label>
<input id="last_name" class="form-control input-group-lg" type="text" name="last_name" title="Enter last name" placeholder="Last name"/>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="email" class="sr-only">Email</label>
<input id="email" class="form-control input-group-lg" type="text" name="email" title="Enter Email" placeholder="Your Email"/>
</div>
<div class="form-group col-xs-12">
<label for="remail" class="sr-only">Re-Enter Email</label>
<input id="remail" class="form-control input-group-lg" type="text" name="remail" title="Enter Email" placeholder="Re-Enter Your Email"/>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="password" class="sr-only">Password</label>
<input id="password" class="form-control input-group-lg" type="password" name="password" title="Enter password" placeholder="Password"/>
</div>
</div>
<div class="row">
<p class="birth"><strong>Date of Birth</strong></p>
<div class="form-group col-sm-3 col-xs-6">
<label for="month" class="sr-only"></label>
<select name="day" class="form-control" id="Day">
<option value="Day" disabled selected>Day</option>
<script type="text/javascript">
for(i=1;i<=31;i++)
{
document.write("<option value='"+i+"'>" + i + "</option>");
}
</script>
</select>
</div>
<div class="form-group col-sm-3 col-xs-6">
<label for="month" class="sr-only"></label>
<select name="month" class="form-control" id="Month">
<option value="Month" disabled selected>Month</option>
<script type="text/javascript">
var m=new Array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
for(i=1;i<=m.length-1;i++)
{
document.write("<option value='"+i+"'>" + m[i] + "</option>");
}
</script>
</select>
</div>
<div class="form-group col-sm-6 col-xs-12">
<label for="year" class="sr-only"></label>
<select name="year" class="form-control" id="Year">
<option value="Year" disabled selected>Year</option>
<script type="text/javascript">
for(i=2000;i>=1960;i--)
{
document.write("<option value='"+i+"'>" + i + "</option>");
}
</script>
</select>
</div>
</div>
<div class="form-group gender">
<select name="sex" style="width:120;height:35;font-size:18px;padding:3;">
<option value="Select Sex:"> Select Sex: </option>
<option value="Female"> Female </option>
<option value="Male"> Male </option>
</select>
</div>
<div class="row">
<div class="form-group col-xs-6">
<label for="campus" class="sr-only">Campus</label>
<input id="campus" class="form-control input-group-lg reg_name" type="text" name="campus" title="Enter campus" placeholder="Your campus"/>
</div>
<div class="form-group col-xs-6">
<label for="county" class="sr-only"></label>
<select name="county" class="form-control" id="county">
<option value="county" disabled selected>County</option>
<option value="Baringo">Baringo</option>
<option value="Bomet">Bomet</option>
<option value="Bungoma">Bungoma</option>
<option value="Busia">Busia</option>
<option value="Elgeyo">Elgeyo Marakwet</option>
<option value="Embu">Embu</option>
<option value="Garissa">Garissa</option>
<option value="Homa">Homa Bay</option>
<option value="Isiolo">Isiolo</option>
<option value="Kajiado">Kajiado</option>
<option value="Kakamega">Kakamega</option>
<option value="Kericho">Kericho</option>
<option value="Kiambu">Kiambu</option>
<option value="Kilifi">Kilifi</option>
<option value="Kirinyaga">Kirinyaga</option>
<option value="Kisii">Kisii</option>
<option value="Kisumu">Kisumu</option>
<option value="Kitui">Kitui</option>
<option value="Kwale">Kwale</option>
<option value="Laikipia">Laikipia</option>
<option value="Lamu">Lamu</option>
<option value="Machakos">Machakos</option>
<option value="Makueni">Makueni</option>
<option value="Mandera">Mandera</option>
<option value="Meru">Meru</option>
<option value="Migori">Migori</option>
<option value="Marsabit">Marsabit</option>
<option value="Mombasa">Mombasa</option>
<option value="Muranga">Muranga</option>
<option value="Nairobi">Nairobi</option>
<option value="Nakuru">Nakuru</option>
<option value="Nandi">Nandi</option>
<option value="Narok">Narok</option>
<option value="Nyamira">Nyamira</option>
<option value="Nyandarua">Nyandarua</option>
<option value="Nyeri">Nyeri</option>
<option value="Samburu">Samburu</option>
<option value="Siaya">Siaya</option>
<option value="Taita">Taita Taveta</option>
<option value="Tana">Tana River</option>
<option value="Tharaka">Tharaka Nithi</option>
<option value="Trans">Trans Zoia</option>
<option value="Turkana">Turkana</option>
<option value="Uasin">Uasin Gishu</option>
<option value="Vihiga">Vihiga</option>
<option value="Wajir">Wajir</option>
<option value="West">West Pokot</option>
</select>
</div>
</div>
<button type="submit" name="signup" id="sign_button" class="btn btn-primary" / onClick="time_get()" >Register Now</button>
</form>
</div>
<div class="tab-pane" id="login">
<h3>Login</h3>
<p class="text-muted">Log into your account</p>
<!--Login Form-->
<form method="post" name="Login_form" id='Login_form'>
<div class="row">
<div class="form-group col-xs-12">
<label for="my-email" class="sr-only">Email</label>
<input id="my-email" class="form-control input-group-lg" type="text" name="username" title="Enter Email" placeholder="Your Email"/>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="my-password" class="sr-only">Password</label>
<input id="my-password" class="form-control input-group-lg" type="password" name="password" title="Enter password" placeholder="Password"/>
</div>
</div>
<p>Forgot Password</p>
<button name="Login" id="login_button" class="btn btn-primary">Login Now</button>
</form><!--Login Form Ends-->
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-6">
<!--Social Icons-->
<ul class="list-inline social-icons">
<li><i class="icon ion-social-facebook"></i></li>
<li><i class="icon ion-social-twitter"></i></li>
<li><i class="icon ion-social-googleplus"></i></li>
<li><i class="icon ion-social-pinterest"></i></li>
<li><i class="icon ion-social-linkedin"></i></li>
</ul>
</div>
</div>
</div>
</div>
<!--preloader-->
<div id="spinner-wrapper">
<div class="spinner"></div>
</div>
<!-- Scripts
================================================= -->
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.appear.min.js"></script>
<script src="js/jquery.incremental-counter.js"></script>
<script src="js/script.js"></script>
</body>
</html>
<?php
include("saga_files/saga_index_file/saga_erorr_file/saga_erorr.php");
?>
</body>
</html>
1) Your session doesn't preserve its state, e.g. it's closed immediately after your login.php page finished processing. That happens because you're calling session_start() inside your code in login.php. So, you must move your session_start() to the first line in login.php. No code should reside before it.
And use it ONLY ONCE! (You use session_start twice)
See: PHP session for tracking unique page views
2) Also: Login_form needs an action attribute (login.php). Otherwise the form is posted to the page were it resides, e.g to index.php. So:
<form method="post" action="login.php" name="Login_form" id="Login_form">
3) And there is a typo here (/):
<button type="submit" name="signup" id="sign_button" class="btn btn-primary" / onClick="time_get()" >Register Now</button>
Good luck.
<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');
}
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.