html传值给php

html传值给php,第1张

<html>

<head>

<meta http-equiv="Content-Type" content="text/html charset=utf-8" />

<title>无标题文档</title>

</head>

<body>

<form action="" method="get">

Name: <input type="text" name="name" />

<input type="submit" />

</form>

<?php

$name=$_GET['name']

echo "欢迎你:".$name

?>

</body>

</html>

通过session来储存

<?phpsession_start()

$_SESSION['username'] = "userName"?>

在其它页面直接取出就行了

<?

session_start()

echo $_SESSION['username']

?>

通过url传向其它页面传递参数

other.php?user=xxx

或在php重定向到其它页面时

$username = "xxx"

$home_url = 'logIn.php?user='.$username header('Location:'.$home_url)

其它页面用$_GET["user"]来接收

3.通过表单向其它页面传送参数

其它页面用$_POST["user"]来接收


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6123394.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存