将表单值传递到我的php数据数组中
我有一个简单的用户名和密码表单,如何将通过用户输入的值传递到我的php数组中 我的阵列将表单值传递到我的php数据数组中,php,arrays,curl,post,Php,Arrays,Curl,Post,我有一个简单的用户名和密码表单,如何将通过用户输入的值传递到我的php数组中 我的阵列 $post_data = array( 'username' => 'user', 'password' => 'pass#', ); <form action=""> <div class=""> <label><b>Username</b></label>
$post_data = array(
'username' => 'user',
'password' => 'pass#',
);
<form action="">
<div class="">
<label><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
</div>
</form>
<?php
session_start();
$service_url = 'http://localhost/app/sapi/user/login.xml'; // .xml asks for xml data in response
$post_data = array(
'username' => 'user',
'password' => 'pass#',
);
$post_data = http_build_query( $post_data, '', '&' ); // Format post data as application/x-www-form-urlencoded
带数组的表单
$post_data = array(
'username' => 'user',
'password' => 'pass#',
);
<form action="">
<div class="">
<label><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
</div>
</form>
<?php
session_start();
$service_url = 'http://localhost/app/sapi/user/login.xml'; // .xml asks for xml data in response
$post_data = array(
'username' => 'user',
'password' => 'pass#',
);
$post_data = http_build_query( $post_data, '', '&' ); // Format post data as application/x-www-form-urlencoded
用户名
密码
登录
输入名称作为键传入post或get数组:
$_GET['uname'] and $_GET['psw'].
如果将表单设置为post(建议登录时使用):
因此,在你的情况下:
if(isset($_POST['uname']) && isset($_POST['psw']))
{
$post_data = array(
'username' => $_POST['uname'],
'password' => $_POST['psw'],
);
}
输入名称作为键传入post或get数组:
$_GET['uname'] and $_GET['psw'].
如果将表单设置为post(建议登录时使用):
因此,在你的情况下:
if(isset($_POST['uname']) && isset($_POST['psw']))
{
$post_data = array(
'username' => $_POST['uname'],
'password' => $_POST['psw'],
);
}