PHP的两边有空格,我可以';你不能摆脱吗?
嘿,我已经用php创建了一个网页电子邮件联系人表单,然后想将其添加到原始网页中,但决定将页面中的所有html放入php文件,然后运行php文件。但两边似乎有一个奇怪的,不一致的空格,空白:0;不会删除,html中的sae代码没有任何空格(因为没有php,所以只有奇数文本)。同时,屏幕上的空白也会变得越来越小……然后再次变大,然后再次变小。我不知道为什么会这样 旁注:实际的电子邮件功能并不是完美无缺的,但我现在并不关注这一点 编辑:基本上在页面的两边都有空白,我想去掉它。边距0不起作用,我的index.php文件中的相同代码在作为HTML放入JSFIDLE时没有空格,因此我认为可能需要用另一种方式为php完成 我还注意到,当我检查它时,空格不知何故是身体的一部分 PHP: form_process.php:PHP的两边有空格,我可以';你不能摆脱吗?,php,html,css,twitter-bootstrap,Php,Html,Css,Twitter Bootstrap,嘿,我已经用php创建了一个网页电子邮件联系人表单,然后想将其添加到原始网页中,但决定将页面中的所有html放入php文件,然后运行php文件。但两边似乎有一个奇怪的,不一致的空格,空白:0;不会删除,html中的sae代码没有任何空格(因为没有php,所以只有奇数文本)。同时,屏幕上的空白也会变得越来越小……然后再次变大,然后再次变小。我不知道为什么会这样 旁注:实际的电子邮件功能并不是完美无缺的,但我现在并不关注这一点 编辑:基本上在页面的两边都有空白,我想去掉它。边距0不起作用,我的ind
<?php
// define variables and set to empty values
$fname_error = $lname_error = $email_error = $phone1_error = $phone2_error = $phone3_error = $message_error="";
$fname = $lname = $email = $phone1 = $phone2 = $phone3 = $message = $success = "";
//form is submitted with POST method
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["fname"])) {
$fname_error = "Name is required";
} else {
$fname = test_input($_POST["fname"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$fname)) {
$fname_error = "Only letters and white space allowed";
}
}
if (empty($_POST["lname"])) {
$lname_error = "Name is required";
} else {
$lname = test_input($_POST["lname"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$fname)) {
$lname_error = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$email_error = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$email_error = "Invalid email format";
}
}
if (empty($_POST["phone1"])) {
$phone1_error = "required";
} else {
$phone1 = test_input($_POST["phone1"]);
// check if e-mail address is well-formed
}
if (empty($_POST["phone2"])) {
$phone2_error = "required";
} else {
$phone2 = test_input($_POST["phone2"]);
// check if e-mail address is well-formed
}
if (empty($_POST["phone3"])) {
$phone3_error = "required";
} else {
$phone3 = test_input($_POST["phone3"]);
// check if e-mail address is well-formed
}
if (empty($_POST["url"])) {
$url_error = "";
} else {
$url = test_input($_POST["url"]);
// check if URL address syntax is valid (this regular expression also allows dashes in the URL)
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$url)) {
$url_error = "Invalid URL";
}
}
if (empty($_POST["message"])) {
$message_error = "Message is required";
} else {
$message = test_input($_POST["message"]);
}
if ($fname_error == '' and $lname_error == '' and $email_error == '' and $phone1_error == '' and $phone2_error == '' and $phone3_error == '' and $url_error == '' ){
$message_body = '';
unset($_POST['submit']);
foreach ($_POST as $key => $value){
$message_body .= "$key: $value\n";
}
$to = 'thetalhasuboor@gmail.com';
$subject = 'Contact Form Submit';
if (mail($to, $subject, $message_body)){
$success = "Message sent, thank you for contacting us!";
$fname = $lname = $email = $phone1 = $phone2 = $phone3 = $message = $url = '';
}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
如果我理解正确,您想删除php标记之间的空格吗?
因此,您可以尝试css代码:
.form-control {margin:0;padding:0;}
您可以尝试删除
,
也许这是有原因的 请你详细说明一下你的问题好吗?你到底想要什么?我想去掉php文件两边的空白。所以你不想在我们的页面中使用两边间距?不,我不想使用两边间距。我想让内容从一个边缘转到另一个边缘。form_process.php的内容是什么?在浏览器中打开源代码视图并对其进行目视检查,它有时会使问题所在的位置变得明显。网页的左右两侧都有空白,我希望它从一个边缘延伸到另一个边缘。我的Imgur相册链接显示了它目前的链接。整个网页的两侧都有空白,我想去掉它,背景足够大吗?不,不是,它没有边对边,两边都有空白
<?php
// define variables and set to empty values
$fname_error = $lname_error = $email_error = $phone1_error = $phone2_error = $phone3_error = $message_error="";
$fname = $lname = $email = $phone1 = $phone2 = $phone3 = $message = $success = "";
//form is submitted with POST method
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["fname"])) {
$fname_error = "Name is required";
} else {
$fname = test_input($_POST["fname"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$fname)) {
$fname_error = "Only letters and white space allowed";
}
}
if (empty($_POST["lname"])) {
$lname_error = "Name is required";
} else {
$lname = test_input($_POST["lname"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$fname)) {
$lname_error = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$email_error = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$email_error = "Invalid email format";
}
}
if (empty($_POST["phone1"])) {
$phone1_error = "required";
} else {
$phone1 = test_input($_POST["phone1"]);
// check if e-mail address is well-formed
}
if (empty($_POST["phone2"])) {
$phone2_error = "required";
} else {
$phone2 = test_input($_POST["phone2"]);
// check if e-mail address is well-formed
}
if (empty($_POST["phone3"])) {
$phone3_error = "required";
} else {
$phone3 = test_input($_POST["phone3"]);
// check if e-mail address is well-formed
}
if (empty($_POST["url"])) {
$url_error = "";
} else {
$url = test_input($_POST["url"]);
// check if URL address syntax is valid (this regular expression also allows dashes in the URL)
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$url)) {
$url_error = "Invalid URL";
}
}
if (empty($_POST["message"])) {
$message_error = "Message is required";
} else {
$message = test_input($_POST["message"]);
}
if ($fname_error == '' and $lname_error == '' and $email_error == '' and $phone1_error == '' and $phone2_error == '' and $phone3_error == '' and $url_error == '' ){
$message_body = '';
unset($_POST['submit']);
foreach ($_POST as $key => $value){
$message_body .= "$key: $value\n";
}
$to = 'thetalhasuboor@gmail.com';
$subject = 'Contact Form Submit';
if (mail($to, $subject, $message_body)){
$success = "Message sent, thank you for contacting us!";
$fname = $lname = $email = $phone1 = $phone2 = $phone3 = $message = $url = '';
}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
.form-control {margin:0;padding:0;}