php forms

Solutions on MaxInterview for php forms by the best coders in the world

showing results for - "php forms"
Adama
05 May 2019
1/* POST */
2<?php
3/* Receiving form Varibles $_POST */
4if(isset($_POST)) {
5  echo("Name : ".$_POST["name"]."<br>E-mail :".$_POST["email"]."<br><br>");
6}
7?>
8      
9<!-- POST -->   
10<html>
11<body>
12
13<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
14Name: <input type="text" name="name"><br>
15E-mail: <input type="text" name="email"><br>
16<input type="submit">
17</form>
18
19
20</body>
21</html>
22/* GET */
23<?php
24/* Receiving form Varibles $_GET */
25if(isset($_GET)) {
26  echo("Name : ".$_GET["name"]."<br>E-mail :".$_GET["email"]."<br><br>");
27}
28?>
29      
30<!-- GET -->   
31<html>
32<body>
33
34<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
35Name: <input type="text" name="name"><br>
36E-mail: <input type="text" name="email"><br>
37<input type="submit">
38</form>
39
40
41</body>
42</html>
43<!-- POST is the secure way of using forms ! -->
Valentino
01 Jan 2020
1<?php 
2$errors=['email'=>'','title'=>'','ingredients'=>''];
3$email=$title=$ingridients='';
4
5if(isset($_POST['submit'])){
6    if(empty($_POST['email'])){
7        $errors['email']= 'email is empty <br>';
8    }else{
9        $email = $_POST['email'];
10        if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
11            $errors['email']= 'email is not valid <br>';
12        }
13    }
14    if(empty($_POST['title'])){
15        $errors['title']= 'title is empty <br>';
16    }else{
17        $title = $_POST['title'];
18        if(!preg_match('/^[a-zA-Z\s]+$/',$title)){
19            $errors['title']='title is not valid <br>';
20        }
21    }
22    if(empty($_POST['ingredients'])){
23        $errors['ingredients']= 'ingredients are empty';
24    }else{
25        $ingridients = $_POST['ingredients'];
26        if(!preg_match('/^([a-zA-Z\s]+)(,\s*[a-zA-Z\s]*)*$/',$ingridients)){
27            $errors['ingredients']= 'invalid type <br>';
28
29        }
30    }
31    if(array_filter($errors)){
32        echo 'there is/are an error/s';
33    }else{
34        header('Location: ../index.php');
35    }
36}
37
38
39
40?>
41
42
43
44
45
46
47<!DOCTYPE html>
48<html>
49	
50	<?php include('../template/header.php'); ?>
51
52	<section class="container grey-text">
53		<h4 class="center">Add a Pizza</h4>
54		<form class="white" action="add2.php" method="POST">
55			<label>Your Email</label>
56			<input type="text" name="email" value="<?php echo htmlspecialchars($email); ?>">
57            <div class="red-text"><?php echo $errors['email']; ?></div>
58			<label>Pizza Title</label>
59			<input type="text" name="title" value="<?php echo htmlspecialchars($title); ?>" >
60            <div class="red-text"><?php echo $errors['title']; ?></div>
61			<label>Ingredients (comma separated)</label>
62			<input type="text" name="ingredients" value="<?php echo htmlspecialchars($ingridients); ?>">
63            <div class="red-text"><?php echo $errors['ingredients']; ?></div>
64			<div class="center">
65				<input type="submit" name="submit" value="Submit"  class="btn brand z-depth-0">
66			</div>
67		</form>
68	</section>
69
70	<?php include('../template/footer.php'); ?>
71
72</html>
queries leading to this page
where can i find sample action page phpform and php 3cform phpphp html formshow does a php form workinput data in phpsimple html form with phphtml and php formsphp form htmlwhat does php do for formsphp form how to usehow to use a form phpget gform phpform using phpform method in phpform for phpphp form examplehow to write php code to create a formhow to implement php formform submission php with comments 5cphp form sqlphp in formsphp formphpbest way of form in phpwhat is form in phpphp form buttonhtml form with php 5cform php scriptform submit in phpphp but is in form input submitform data in phpform with phpform action submit phpphp ful formhtml with php formphp field controlhtml php formphp show formphp submitform in php htmlform html phphow to use php formsa form in phpphp w3schools php formhow to submit form using phpsubmit form in php codefunctions and forms in phpphp forms exampleshtml form page with phpform and php code net php formform in php codehow to work with form and phpform html 3e phpphp formnphp formsform tags in phpform php examplephp simple formform phpphp formform method phphow to create form in phpphp submit formmake a php formphp html form submitforms with phpusing forms with phpphp form codeform php codeform submitting phphow to make php formphp form basicform display in phpbasic php input formphp html formphp formeform html with phpphp with formsform phphtml forms in phpsubmit form phpphp form event submitphp forms methodform phphow to submit formin phpform example phpphp porm ostphp formphp code of formform button phpforms phpphp form html exampleforms and functions in phpbasic form phphtml to php formform php phow create a submit from in phpphp form with phpphp and formsform en phpform in form phphtml form phpphp formasphp html form form php htmlforms in phphow to connect form in index html in phppphp form inputhtml form to phpphp process input from htmlpost php submit buttondiffrerence between form class and form method in phpformr phpphp forms tutorialhtml form in phpmake php formwat is form phpphp form submit simple php form handlingphp form programhow to get input from form in phphtml form with phpphp from formform in phpphp basic formhtml in form phpform in php examplephp form methodphp form 2cphp form tag codephp form inphpphp in an html formbutton type with echophp action formbasic php formphp code for formsubmit button function phphow to submit a form in phphtml form for phpsubmit form in phpphp form in formform to phpphp formuphp fromsphp form in htmlhtml number type post method phpphp form submit examplehow does php form workin php what is a formhow to make form phpphp html formforms by phphow to create submit button in phpphp form 24thishow to post form phpphp code with a formphp function for formhow to create a php formform in html phptaking values from form in phpis php needed in formform function in phpform html and phpform code phphow to get data from form phpwhat is a php form 3fhow to make a php formphp forms