PHP, linking variables to a specific date in a form -


how can assign variable specific date use in form?

i want warning appear when user tries book many people on specific date. started writing code didn't know go there:

<?php        $spaces = 20;     $num_people = get('#people');     $message = "unfortunately don't have many spaces avilable on date. have maximum of $spaces.";      if($spaces < $num_people) {       echo $message;     } 

?>

how assign value $spaces specific date , link form? here form:

<form method="post">     name:<br>     <textarea id="name"></textarea><br>     <br>     date leaving:<br>     <br>     <textarea id="date"></textarea><br>     <br>     how many people?:<br>     <textarea id="people"></textarea><br>     <br>     <input type="submit"> 

$num_people = get('#people');

this line should be

$num_people = $_get['people'];

and

<textarea id="people"></textarea><br>

shoul be

<textarea id="people" name="people"></textarea><br>

and method ahould get. since sending get request.

your code should this:

<?php    if(isset($_get['people'])){  $spaces = 20; $num_people = $_get['people']; $message = "unfortunately don't have many spaces avilable on date. have maximum of $spaces.";  if($spaces < $num_people) {   echo $message; }  } ?>   <form method="get" action=""> name:<br> <textarea id="name"></textarea><br> <br> date leaving:<br> <br> <textarea id="date"></textarea><br> <br> how many people?:<br> <textarea id="people" name="people"></textarea><br> <br> <input type="submit"> 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -