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> 

3.86
7

                                     &lt;form action=&quot;demo/request-variable.php&quot; method=&quot;post&quot;&gt;

&lt;input type=&quot;text&quot; name=&quot;firstname&quot; placeholder=&quot;First Name&quot; /&gt;

&lt;input type=&quot;text&quot; name=&quot;lastname&quot; placeholder=&quot;Last Name&quot; /&gt;

&lt;input type=&quot;submit&quot; name=&quot;submit&quot; /&gt;
&lt;/form&gt; 

3.86 (7 Votes)
0
4
4
VoidKing 95 points

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

4 (4 Votes)
0
4.33
3
Indy 130 points

                                     name1=firstValue&amp;name2=secondValue&amp;name3=thirdValue 

4.33 (3 Votes)
0
4.33
9
Sohail 85 points

                                    // 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 '&lt;h3&gt;Form POST Method&lt;/h3&gt;'; echo 'Your name is ' . $lastname . ' ' . $firstname; exit; } 

4.33 (9 Votes)
0
0
0

                                     &lt;form action=&quot;get-method.php&quot; method=&quot;get&quot;&gt; &lt;input type=&quot;text&quot; name=&quot;firstname&quot; placeholder=&quot;First Name&quot; /&gt; &lt;input type=&quot;text&quot; name=&quot;lastname&quot; placeholder=&quot;Last Name&quot; /&gt; &lt;input type=&quot;submit&quot; name=&quot;submit&quot; /&gt; &lt;/form&gt; 

0
0
0
0

                                     // 

0
0
4
8
Xiagua 130 points

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

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

4 (8 Votes)
0
3
1

                                     // 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 '&lt;h3&gt;Form GET Method&lt;/h3&gt;'; echo 'Your name is ' . $lastname . ' ' . $firstname; exit;
}

3 (1 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source