gpt4 book ai didi

php - 无法插入数据库

转载 作者:太空宇宙 更新时间:2023-11-03 10:42:50 25 4
gpt4 key购买 nike

我试图在表格中插入联系我们的详细信息,但我不能,我试过了,但我仍然不能,为什么?我做错了什么?

任何帮助都会有很大的帮助,我尝试以其他形式进行,但没问题,这些数据没有通过

HTML

     <div class="wrap-embed-contact-form">
<form name="testing122" action="post.php" method="post" class="embed- contact-form" >
<div class="form-heading">Contact Us</div>
<div class="form-sub-heading">Please, fill in the form to get in touch!</div>
<hr>
<div class="form-message hide">
Your message has been sent successfully!
</div>
<div class="form-content">
<div class="group">
<label for="name" class="empty"></label>
<div><input id="name" name="name" placeholder="Your Name" class="form-control"></div>
</div>
<div class="group">
<label for="email" class="empty"></label>
<div><input type="email" name="email" placeholder="Your Email" class="form-control"></div>
</div>
<div class="group">
<label for="query-type">Query type</label>
<div>
<select id="query-type" name="query-type" class="form-control">
<option value="General Query">General Query</option>
<option value="Presale">Courses Query</option>
<option value="Technical">Addmission</option>
<option value="Others">Others</option>
</select>
</div>
</div>
<div class="group">
<label for="message" class="empty"></label>
<div><textarea id="message" name="message" placeholder="Your Message" class="form-control" rows="5"></textarea></div>
</div>
<div class="group">
<label class="empty"></label>
<div><button class="btn-submit" type="submit">Send Message</button></div>
</div>
</div>
<a class="btn-show-contact" href="#contact"><img src="<?php echo $path; ?>img/btn_contact.png"></a>
</form>

Post.php

       <?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("aptech", $con);

$sql="INSERT INTO contact (post_name,post_email,post_type,message)
VALUES
('$_POST[name]','$_POST[email]','$_POST[query-type]','$_POST[message]')";

mysql_close($con);
?>

最佳答案

您忘记运行查询。

  mysql_select_db("aptech", $con);

$sql="INSERT INTO contact (post_name,post_email,post_type,message)
VALUES
('$_POST[name]','$_POST[email]','$_POST[query-type]','$_POST[message]')";

mysql_query($sql); // <---------- You forgot this!

mysql_close($con);

关于php - 无法插入数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35504126/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com