php-PHP新手问一个小问题,有时间前辈帮帮忙!小弟在此感激不尽!

WBOY
Release: 2016-06-02 11:31:12
Original
855 people have browsed it

php

php写的一个简单提交数据代码没提示错误 但是数据库添加不进去
index.php代码如下:

<code> <?php require_once 'conn.php';    $id = $_POST[userid];    $name = $_POST[username];    $content = $_POST[content];    $sql = "insert into all(userid,name,content)values('$id','$name','$content')";    $res = mysql_query($sql);    if(!$res)    {        echo "数据添加失败!";     }?><meta http-equiv="content-type" content="text/html ;charset=utf-8">
<form action="" method="post">编号:<input type="text" name="userid"><br>用户:<input type="text" name="username"><br>留言:<textarea name="content"></textarea><br><input type="submit" value="提交">
</form></code>
Copy after login

conn.php代码如下

<code> <?php $conn = mysql_connect("localhost","root","root")or die("数据库连接失败!");    $db = mysql_select_db("web");    mysql_query("set names utf-8");?></code>
Copy after login

小弟在此谢谢大家啦!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template