how to form data to another file in php code example

Example 1: how to form data to another file in php

<form action="post-method.php" method="post">

<input type="text" name="firstname" placeholder="First Name" />

<input type="text" name="lastname" placeholder="Last Name" />

<input type="submit" name="submit" />
</form>

Example 2: how to form data to another file in php

name1=firstValue&name2=secondValue&name3=thirdValue

Example 3: how to form data to another file in php

$firstname = preg_replace( "#[^\w]#", "", $_POST['firstname'] );

$lastname = preg_replace( "#[^\w]#", "", $_POST['lastname'] );

Example 4: how to form data to another file in php

preg_replace( $pattern, $replacement, $subject, $limit, $count )

Example 5: how to form data to another file in php

<form action="demo/request-variable.php" method="post">

<input type="text" name="firstname" placeholder="First Name" />

<input type="text" name="lastname" placeholder="Last Name" />

<input type="submit" name="submit" />
</form>

Example 6: how to form data to another file in php

// Check if the form is submitted if ( isset( $_GET['submit'] ) ) { // retrieve the form data by using the element's name attributes value as key $firstname = $_GET['firstname']; $lastname = $_GET['lastname']; // display the results echo '<h3>Form GET Method</h3>'; echo 'Your name is ' . $lastname . ' ' . $firstname; exit;
}

Example 7: how to form data to another file in php

<form action="get-method.php" method="get"> <input type="text" name="firstname" placeholder="First Name" /> <input type="text" name="lastname" placeholder="Last Name" /> <input type="submit" name="submit" /> </form>

Example 8: how to form data to another file in php

// Check if the form is submitted if ( isset( $_POST['submit'] ) ) { // retrieve the form data by using the element's name attributes value as key $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; // display the results
echo '<h3>Form POST Method</h3>'; echo 'Your name is ' . $lastname . ' ' . $firstname; exit; }

Tags:

Php Example