everybody! I need your help or my head will blow up soon! I feel the solution is easy but... When user enters ID and Date and clicks Submit button he must be redirected to the devis.php page with the client id entered before. Here is the initial code
<?php
include("db.php");
if( isset( $_REQUEST['submit'] ) )
{
$id=$_POST['client'];
$date=$_POST['calendar'];
?>
<h1>IDENTITE CLIENT:</h1>
<label>Client ID <input type="text" name="client" ></label>
<br>
<br>
<label>Date de 1ere intervention <input type="date" name="calendar"> </label>
<br>
<a href="devis.php?id=<?php echo $id; ?>&date=<?php echo $date; ?>"><input type="submit" name="submit" value="submit" ></a>
But in this code the inputs can be visible only after clicking Submit and if to get them out of php tags, the variable Id isn't recognised and no redirection is following.
Thank you for your help and time!
ADD THIS TO YOUR PHP CODE
if( isset( $_REQUEST['submit'] ) )
{
$id=$_POST['client'];
$date=$_POST['calendar'];
header('location:devis.php?id='.$id.'&date='.$date);
}
And set form action attribute to blank action=""
The easiest way to do this is make a form like this:
<form method = "POST" action = "devis.php">
<h1>IDENTITE CLIENT:</h1>
<label>Client ID <input type="text" name="client" ></label>
<br>
<br>
<label>Date de 1ere intervention <input type="date" name="calendar"> </label>
<br>
<input type="submit" name="submit" value="submit" ></a>
</form>
now in devis.php, you should be able to get the ID from previous page like this:
if ( isset($_POST['submit']) )
{
$id = $_POST['client']; // ID inputted from the previous page.
}
Create a normal HTML form along with your required inputs
inside form
with post
method and action
with value devis.php
since you want to redirected to devis.php
HTML
<html>
<head></head>
<body>
<form method="post" action="devis.php">
<label>Client ID :</label><input type="text" name="client" ><br><br>
<label>Date de 1ere intervention:</label> <input type="date" name="calendar"> <br><br>
<input type="submit" name="submit" value="submit" >
</form>
</body>
</html>
Your devis.php
page should do it. Here I am just echo
-ing the values just to give you a clue of how to retrieve it. You can use it the way you want.
devis.php
<?php
if(isset($_POST["client"]){
echo 'Client ID: '.$_POST["client"].'<br>';
}
if(isset($_POST["calendar"]){
echo 'Date: '.$_POST["calendar"];
}
?>