我想在按下同一站点的 html 按钮时转到其他 php 页面。我已经通过使用 header 函数进行了尝试,但它没有用。
这是简单的html代码:
<input type="button" name="Insert_Ad" value="Post and ad">
如果用户单击此按钮,它将把它带到另一个 PHP 页面,例如 URL 地址 'http://localhost/Product.php/Product.php'
这是我想继续按下按钮的 PHP 页面的代码
<html>
<head>
<meta charset="UTF-8">
<title>Insert form data</title>
</head>
<body>
<form method="post" action ="Product.php" id="contact-form">
<input type="text" name="product_category" placeholder="product_category" required />
<input type="text" name="product_name" placeholder="product_name" required />
<textarea id = "address" name="product_description" placeholder="product_description" required /></textarea>
<input type="text" name="product_image1" placeholder="product_image1" required />
<input type="text" name="product_image2" placeholder="product_image2" required />
<input type="text" name="product_image3" placeholder="product_image3" required />
<input type="text" name="product_image4" placeholder="product_image4" required />
<input type="text" name="product_image5" placeholder="product_image5" required />
<div class="btn-group" role="group">
<input type="submit" class="btn btn-default" name="Add" value="Enter the box" style="margin-top: 15px; margin-right: 15px; border-radius: 4px;">
</div>
</form>
<?php
$servername = "localhost";
$username = "root";
$password = "zz224466";
$dbname = "zain";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_POST['Add']))
{
$product_category = $_POST['product_category'];
$product_name = ($_POST['product_name']);
$product_description = ($_POST['product_description']);
$product_image1 = ($_POST['product_image1']);
$product_image2 = ($_POST['product_image2']);
$product_image3 = ($_POST['product_image3']);
$product_image4 = ($_POST['product_image4']);
$product_image5 = ($_POST['product_image5']);
$sql = "INSERT INTO zain.product (product_category,product_name,product_description,product_image1,product_image2,product_image3,product_image4,product_image5)
VALUES ('$product_category','$product_name','$product_description','$product_image1','$product_image2','$product_image3','$product_image4','$product_image5')";
mysqli_query($conn,$sql);
if (mysqli_query($conn,$sql))
{
echo "New record created successfully";
}
else
{
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>
</body>
</html>
请教我怎么做
最佳答案
这是最简单的方法:
<input type="button" name="Insert_Ad" value="Post and ad" onclick="location.href='your_url_here'">
或者您可以使用表单提交给给定的 url:
<form action="your_url_here">
<input type="submit" name="Insert_Ad" value="Post and ad">
</form>
关于PHP:如何在按下 html 按钮时更改 php 页面的 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34963819/
出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits
如何正确创建Rails迁移,以便将表更改为MySQL中的MyISAM?目前是InnoDB。运行原始执行语句会更改表,但它不会更新db/schema.rb,因此当在测试环境中重新创建表时,它会返回到InnoDB并且我的全文搜索失败。我如何着手更改/添加迁移,以便将现有表修改为MyISAM并更新schema.rb,以便我的数据库和相应的测试数据库得到相应更新? 最佳答案 我没有找到执行此操作的好方法。您可以像有人建议的那样更改您的schema.rb,然后运行:rakedb:schema:load,但是,这将覆盖您的数据。我的做法是(假设
我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h
如何在buildr项目中使用Ruby?我在很多不同的项目中使用过Ruby、JRuby、Java和Clojure。我目前正在使用我的标准Ruby开发一个模拟应用程序,我想尝试使用Clojure后端(我确实喜欢功能代码)以及JRubygui和测试套件。我还可以看到在未来的不同项目中使用Scala作为后端。我想我要为我的项目尝试一下buildr(http://buildr.apache.org/),但我注意到buildr似乎没有设置为在项目中使用JRuby代码本身!这看起来有点傻,因为该工具旨在统一通用的JVM语言并且是在ruby中构建的。除了将输出的jar包含在一个独特的、仅限ruby
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende
从给定URL下载文件并立即将其上传到AmazonS3的更直接的方法是什么(+将有关文件的一些信息保存到数据库中,例如名称、大小等)?现在,我既不使用Paperclip,也不使用Carrierwave。谢谢 最佳答案 简单明了:require'open-uri'require's3'amazon=S3::Service.new(access_key_id:'KEY',secret_access_key:'KEY')bucket=amazon.buckets.find('image_storage')url='http://www.ex
我正在编写一个小脚本来定位aws存储桶中的特定文件,并创建一个临时验证的url以发送给同事。(理想情况下,这将创建类似于在控制台上右键单击存储桶中的文件并复制链接地址的结果)。我研究过回形针,它似乎不符合这个标准,但我可能只是不知道它的全部功能。我尝试了以下方法:defauthenticated_url(file_name,bucket)AWS::S3::S3Object.url_for(file_name,bucket,:secure=>true,:expires=>20*60)end产生这种类型的结果:...-1.amazonaws.com/file_path/file.zip.A
在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这