简体   繁体   中英

php passing data form

I use the GET method to pass data from index.php to profile.php

index.php code is

<html>
<body>

<form action="profile.php" method="GET">
username: <input type="text" username="user"><br>
password: <input type="password" name="pass"><br>
<input type="submit">
</form>

<button type="button" onclick="alert('task success')"/>click me"</button>

</body>
</html>

profile.php code is

<?php
    echo " username: "$_GET ['username']."; password "$_GET['pass'];
?>

the output is 在此处输入图像描述

it es pass the inputs of the form successfully but I need it to appear in profile.php file

how can I make the output appear in profile.php page?

any help please

The problem is that the page is redirected. You will need to send an AJAX request to the action that you want to execute. With jQuery you can prevent a form from submitting like this:

$('form').submit(function (evt) {
   evt.preventDefault(); //prevents the default action

}

You will need to collect the parameters, send them via AJAX and handle the response .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM