how to make an mail to form work - php

I know it has been asked a lot on this website but i just need to know how to do it.
I've got a code in html on CSS3 for an e-mail form. The only thing that is left for me is to make it work. My website is on the same server as my e-mail.
This is the coding.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML5 Contact Form</title>
<link rel="stylesheet" media="screen" href="styles.css" >
</head>
<body>
<form class="contact_form" action="#" method="post" name="contact_form">
<ul>
<li>
<h2>Contact Us</h2>
<span class="required_notification">* Denotes Required Field</span>
</li>
<li>
<label for="name">Name:</label>
<input type="text" placeholder="John Doe" required />
</li>
<li>
<label for="email">Email:</label>
<input type="email" name="email" placeholder="john_doe#example.com" required />
<span class="form_hint">Proper format "name#something.com"</span>
</li>
<li>
<label for="website">Website:</label>
<input type="url" name="website" placeholder="http://johndoe.com" required pattern="(http|https)://.+"/>
<span class="form_hint">Proper format "http://someaddress.com"</span>
</li>
<li>
<label for="message">Message:</label>
<textarea name="message" cols="40" rows="6" required ></textarea>
</li>
<li>
<button class="submit" type="submit">Submit Form</button>
</li>
</ul>
</form>
</body>
</html>
CSS
/* === Remove input autofocus webkit === */
*:focus {outline: none;}
/* === Form Typography === */
body {font: 14px/21px "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", sans-serif;}
.contact_form h2, .contact_form label {font-family:Georgia, Times, "Times New Roman", serif;}
.form_hint, .required_notification {font-size: 11px;}
/* === List Styles === */
.contact_form ul {
width:750px;
list-style-type:none;
list-style-position:outside;
margin:0px;
padding:0px;
}
.contact_form li{
padding:12px;
border-bottom:1px solid #eee;
position:relative;
}
.contact_form li:first-child, .contact_form li:last-child {
border-bottom:1px solid #777;
}
/* === Form Header === */
.contact_form h2 {
margin:0;
display: inline;
}
.required_notification {
color:#d45252;
margin:5px 0 0 0;
display:inline;
float:right;
}
/* === Form Elements === */
.contact_form label {
width:150px;
margin-top: 3px;
display:inline-block;
float:left;
padding:3px;
}
.contact_form input {
height:20px;
width:220px;
padding:5px 8px;
}
.contact_form textarea {padding:8px; width:300px;}
.contact_form button {margin-left:156px;}
/* form element visual styles */
.contact_form input, .contact_form textarea {
border:1px solid #aaa;
box-shadow: 0px 0px 3px #ccc, 0 10px 15px #eee inset;
border-radius:2px;
padding-right:30px;
-moz-transition: padding .25s;
-webkit-transition: padding .25s;
-o-transition: padding .25s;
transition: padding .25s;
}
.contact_form input:focus, .contact_form textarea:focus {
background: #fff;
border:1px solid #555;
box-shadow: 0 0 3px #aaa;
padding-right:70px;
}
/* === HTML5 validation styles === */
.contact_form input:required, .contact_form textarea:required {
background: #fff url(images/red_asterisk.png) no-repeat 98% center;
}
.contact_form input:required:valid, .contact_form textarea:required:valid {
background: #fff url(images/valid.png) no-repeat 98% center;
box-shadow: 0 0 5px #5cd053;
border-color: #28921f;
}
.contact_form input:focus:invalid, .contact_form textarea:focus:invalid {
background: #fff url(images/invalid.png) no-repeat 98% center;
box-shadow: 0 0 5px #d45252;
border-color: #b03535
}
/* === Form hints === */
.form_hint {
background: #d45252;
border-radius: 3px 3px 3px 3px;
color: white;
margin-left:8px;
padding: 1px 6px;
z-index: 999; /* hints stay above all other elements */
position: absolute; /* allows proper formatting if hint is two lines */
display: none;
}
.form_hint::before {
content: "\25C0";
color:#d45252;
position: absolute;
top:1px;
left:-6px;
}
.contact_form input:focus + .form_hint {display: inline;}
.contact_form input:required:valid + .form_hint {background: #28921f;}
.contact_form input:required:valid + .form_hint::before {color:#28921f;}
/* === Button Style === */
button.submit {
background-color: #68b12f;
background: -webkit-gradient(linear, left top, left bottom, from(#68b12f), to(#50911e));
background: -webkit-linear-gradient(top, #68b12f, #50911e);
background: -moz-linear-gradient(top, #68b12f, #50911e);
background: -ms-linear-gradient(top, #68b12f, #50911e);
background: -o-linear-gradient(top, #68b12f, #50911e);
background: linear-gradient(top, #68b12f, #50911e);
border: 1px solid #509111;
border-bottom: 1px solid #5b992b;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
-o-border-radius: 3px;
box-shadow: inset 0 1px 0 0 #9fd574;
-webkit-box-shadow: 0 1px 0 0 #9fd574 inset ;
-moz-box-shadow: 0 1px 0 0 #9fd574 inset;
-ms-box-shadow: 0 1px 0 0 #9fd574 inset;
-o-box-shadow: 0 1px 0 0 #9fd574 inset;
color: white;
font-weight: bold;
padding: 6px 20px;
text-align: center;
text-shadow: 0 -1px 0 #396715;
}
button.submit:hover {
opacity:.85;
cursor: pointer;
}
button.submit:active {
border: 1px solid #20911e;
box-shadow: 0 0 10px 5px #356b0b inset;
-webkit-box-shadow:0 0 10px 5px #356b0b inset ;
-moz-box-shadow: 0 0 10px 5px #356b0b inset;
-ms-box-shadow: 0 0 10px 5px #356b0b inset;
-o-box-shadow: 0 0 10px 5px #356b0b inset;
}
If some one can help me out it would be a blast.

OK. I created the PHP code that tested and worked.
Firstly replace your HTML cede with this
<form class="contact_form" action="submit.php" method="post" name="contact_form">
<ul>
<li>
<h2>Contact Us</h2>
<span class="required_notification">* Denotes Required Field</span>
</li>
<li>
<label for="name">Name:</label>
<input type="text" name="name" placeholder="John Doe" required />
</li>
<li>
<label for="email">Email:</label>
<input type="email" name="email" placeholder="john_doe#example.com" required />
<span class="form_hint">Proper format "name#something.com"</span>
</li>
<li>
<label for="website">Website:</label>
<input name="website" type="url" name="website" placeholder="http://johndoe.com" required pattern="(http|https)://.+"/>
<span class="form_hint">Proper format "http://someaddress.com"</span>
</li>
<li>
<label for="message">Message:</label>
<textarea name="message" cols="40" rows="6" required ></textarea>
</li>
<li>
<button class="submit" type="submit">Submit Form</button>
</li>
</ul>
</form>
Your CSS will be the same and PHP code is this:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$message = $_POST['message'];
$to = 'your#email.com';
$headers = 'From: '.$email."\r\n" .'Reply-To: '.$email."\r\n" .'X-Mailer: PHP/' . phpversion();
$subject = $subject;
$body.='Name: '.$name."\n";
$body.='Email: '.$email."\n";
$body.='Website: '.$website."\n";
$body.='Message: '."\n".$message."\n";
if(mail($to, $subject, $body, $headers)) {
die('Mail sent');
}
else {
die('Error: Mail failed');
}
?>
In $to on PHP write your email.
Note: You need to write PHP code on submit.php

Related

MAILTO: Form Action Alternative? [duplicate]

This question already has answers here:
Send email with PHP from html form on submit with the same script
(8 answers)
Closed 6 years ago.
So, I want to set up a feedback section on my site, and the code seemed to work just fine in w3school's TryIt Editor but for some reason it didn't work on my site.
I found another question, also here on stack overflow which is pretty similar but I saw this answer...
mailto: form actions depend on browsers and local email clients playing together nicely. They do this so rarely that mailto: form actions are unusable on the WWW.
Replace it with a server side program that sends the email.
Could someone possibly give an example of what this meant? It was pretty vague, I'm assuming they meant something like PHP, but I'm not quite sure.
CSS:
.form-style-1 {
margin:10px auto;
max-width: 400px;
padding: 20px 12px 10px 20px;
font: 13px "Lucida Sans Unicode", "Lucida Grande", sans-serif;
}
.form-style-1 li {
padding: 0;
display: block;
list-style: none;
margin: 10px 0 0 0;
}
.form-style-1 label{
margin:0 0 3px 0;
padding:0px;
display:block;
font-weight: bold;
}
.form-style-1 input[type=text],
.form-style-1 input[type=date],
.form-style-1 input[type=datetime],
.form-style-1 input[type=number],
.form-style-1 input[type=search],
.form-style-1 input[type=time],
.form-style-1 input[type=url],
.form-style-1 input[type=email],
textarea,
select{
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
border:1px solid #BEBEBE;
padding: 7px;
margin:0px;
-webkit-transition: all 0.30s ease-in-out;
-moz-transition: all 0.30s ease-in-out;
-ms-transition: all 0.30s ease-in-out;
-o-transition: all 0.30s ease-in-out;
outline: none;
}
.form-style-1 input[type=text]:focus,
.form-style-1 input[type=date]:focus,
.form-style-1 input[type=datetime]:focus,
.form-style-1 input[type=number]:focus,
.form-style-1 input[type=search]:focus,
.form-style-1 input[type=time]:focus,
.form-style-1 input[type=url]:focus,
.form-style-1 input[type=email]:focus,
.form-style-1 textarea:focus,
.form-style-1 select:focus{
-moz-box-shadow: 0 0 8px #88D5E9;
-webkit-box-shadow: 0 0 8px #88D5E9;
box-shadow: 0 0 8px #88D5E9;
border: 1px solid #88D5E9;
}
.form-style-1 .field-divided{
width: 49%;
}
.form-style-1 .field-long{
width: 100%;
}
.form-style-1 .field-select{
width: 100%;
}
.form-style-1 .field-textarea{
height: 100px;
}
.form-style-1 input[type=submit], .form-style-1 input[type=button]{
background: #4B99AD;
padding: 8px 15px 8px 15px;
border: none;
color: #fff;
}
.form-style-1 input[type=submit]:hover, .form-style input[type=button]:hover{
background: #4691A4;
box-shadow:none;
-moz-box-shadow:none;
-webkit-box-shadow:none;
}
.form-style-1 .required{
color:red;
}
HTML:
<html>
<head>
</head>
<body>
<form action="MAILTO:feedback#itzjavacraft.tk" method="post" enctype="text/plain">
<ul class="form-style-1">
<li>
<label>
Full Name <span class="required">*</span>
</label>
<input type="text" name="field1" class="field-divided" placeholder="First"/>
<input type="text" name="field2" class="field-divided" placeholder="Last"/>
</li>
<li>
<label>
Email <span class="required">*</span>
</label>
<input type="email" name="field3" class="field-long" />
</li>
<li>
<label>
Subject
</label>
<select name="field4" class="field-select">
<option value="Feedback">Feedback</option>
<option value="Suggestion">Suggestion</option>
<option value="General">General</option>
</select>
</li>
<li>
<label>
Your Message <span class="required">*</span>
</label>
<textarea name="field5" id="field5" class="field-long field-textarea"></textarea>
</li>
<li>
<input type="submit" value="Submit" />
</li>
</ul>
</form>
<body>
Replace it with a server side program that sends the email.
Means, mailto will not work, you need to use any server side
programs to process the email like PHP mail function.
Example:
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com';
mail($to, $subject, $message, $headers);
?>
Learn detail about PHP mail function from PHP.net
You can retrive data from the form and use in the mail function of PHP.

How to get data inputed from dropdown menu in Laravel 5

I'm a newbee in Laravel and i start to do a dropdown login menu
but i don't know how to directly login from this form in Laravel, which don't need using auth/login. Thank you so much!
This is the dropdown sample i try
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.active-links').click(function () {
if ($('#signin-dropdown').is(":visible")) {
$('#signin-dropdown').hide()
$('#session').removeClass('active');
} else {
$('#signin-dropdown').show()
$('#session').addClass('active');
}
return false;
});
$('#signin-dropdown').click(function(e) {
e.stopPropagation();
});
$(document).click(function() {
$('#signin-dropdown').hide();
$('#session').removeClass('active');
});
});
</script>
<style type="text/css">
* {
margin:0;
padding:0;
}
body {
background:#fff;
position:relative;
font:13px Arial, Helvetica, sans-serif;
}
a {
text-decoration:none;
color:#00c6ff;
}
h1 {
font: 4em normal Arial, Helvetica, sans-serif;
padding: 20px; margin-top: 100px;
text-align:center;
}
h1 small{
font: 0.2em normal Arial, Helvetica, sans-serif;
text-transform:uppercase; letter-spacing: 0.2em; line-height: 5em;
display: block;
}
.content {width: 960px; margin: 0 auto; overflow: hidden;}
#top-stuff {
left:0;
position:fixed;
top:0;
width:100%;
z-index:12;
}
#top-bar-out {
display:block;
position:relative;
width:100%;
height:40px;
background: -moz-linear-gradient(center top, #333333, #111111);
background: -webkit-gradient(linear, left top, left bottom, from(#333333), to(#111111));
background: -o-linear-gradient(top, #333333, #111111);
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#333333', EndColorStr='#111111');
box-shadow:0 1px 2px #666666;
-webkit-box-shadow: 0 1px 2px #666666;
}
.active-links {
position:absolute;
right:8px;
top:0;
}
#container {
width:780px;
margin:0 auto;
position: relative;
}
#topnav {
text-align:right;
}
#session {
cursor:pointer;
display:inline-block;
height:20px;
padding:10px 12px;
vertical-align: top;
white-space: nowrap;
}
#session.active, #session:hover {
background:rgba(255,255,255,0.1);
color:fff;
}
a#signin-link {
color:#bababa;
position:relative;
}
a#signin-link em {
font-size:10px;
font-style:normal;
margin-right:4px;
}
a#signin-link strong {
color:#fff;
}
#signin-dropdown {
background-color:#202020;
border-bottom-left-radius:5px;
border-bottom-right-radius:5px;
box-shadow:0 1px 2px #666666;
-webkit-box-shadow: 0 1px 2px #666666;
min-height:200px;
min-width:160px;
position:absolute;
right:0;
display:none;
}
#signin-dropdown form{
cursor:pointer;
padding:10px;
text-align:left;
}
#signin-dropdown .textbox span { color:#BABABA;}
#signin-dropdown .textbox input { width:200px; }
fieldset {
border:none;
}
form.signin .textbox label {
display:block;
padding-bottom:7px;
}
form.signin .textbox span {
display:block;
}
form.signin p, form.signin span {
color:#999;
font-size:11px;
line-height:18px;
}
form.signin .textbox input {
background:#666666;
border-bottom:1px solid #333;
border-left:1px solid #000;
border-right:1px solid #333;
border-top:1px solid #000;
color:#fff;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
font:13px Arial, Helvetica, sans-serif;
padding:6px 6px 4px;
}
form.signin .remb {
padding:9px 0;
position:relative;
text-align:right;
}
form.signin .remb .remember {
text-align:left;
position:absolute;
left:0;
}
.button {
background: -moz-linear-gradient(center top, #f3f3f3, #dddddd);
background: -webkit-gradient(linear, left top, left bottom, from(#f3f3f3), to(#dddddd));
background: -o-linear-gradient(top, #f3f3f3, #dddddd);
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f3f3f3', EndColorStr='#dddddd');
border-color:#000;
border-width:1px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
color:#333;
cursor:pointer;
display:inline-block;
padding:4px 7px;
margin:0;
font:12px;
}
.button:hover { background:#ddd; }
</style>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Signin Dropdown Box with jQuery</title>
</head>
<body>
<div id="top-stuff">
<div id="top-bar-out">
<div id="container">
<div id="topnav">
<div class="active-links">
<div id="session">
<a id="signin-link" href="#">
<em>Have an account?</em>
<strong>Sign in</strong>
</a>
</div>
<div id="signin-dropdown">
<form method="post" class="signin" action="#">
<fieldset class="textbox">
<label class="username">
<span>Username or email</span>
<input id="username" name="username" value="" type="text" autocomplete="on">
</label>
<label class="password">
<span>Password</span>
<input id="password" name="password" value="" type="password">
</label>
</fieldset>
<fieldset class="remb">
<label class="remember">
<input type="checkbox" value="1" name="remember_me" />
<span>Remember me</span>
</label>
<button class="submit button" type="button">Sign in</button>
</fieldset>
<p>
<a class="forgot" href="#">Forgot your password</a>
<br>
<a class="mobile" href="#">Already using Twitter via SMS?</a>
</p>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Please look at you form open tag <form method="post" class="signin" action="#">
In you can see action is # change it to another url that provides authenfication of user, also you will need to add CSRF token, if you didn't disable CSRF protection. To learn how to add it please look documentation

Getting image from html form via php to email

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

How to connect MySQL(WAMP) database with PHP, and handling errors?

Recently I've given a task to create a data inquiry system. The system required user to fill in the form. When it is submitted, the data will be validated by the admin and connected to the database.
This is my form.html:
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>data</title>
<link rel="stylesheet" media="screen" href="styles.css" >
</head>
<body bgcolor="#13b4ff">
<div id="header" style="background-color: #4169E1;"><hr>
<form class="form" action="submit.php" method="post" name="form" >
<ul>
<li>
<span class="required_notification">* Denotes Required Field</span>
</li>
<li>
<label for="name">Name:</label>
<input type="text" name="name" required />
</li>
<li>
<label for="position:">Jawatan:</label>
<input type="text" name="position" />
</li>
<li>
<label for="unit">Unit:</label>
<input type="text" name="unit" required />
</li>
<li>
<label for="institute">Institute:</label>
<input type="text" name="institute" required />
</li>
<li>
<label for="telefon">No. Telefon:</label>
<input type="number" name="telefon" placeholder="eg: 012-345-6789" required />
</li>
<li>
<label for="faks">No. Faks:</label>
<input type="number" name="faks" placeholder="eg: 03-12345678" />
</li>
<li>
<label for="email">E-mail:</label>
<input type="email" name="name" placeholder="name#something.com"/ required>
<span class="form_hint">proper format<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script></span>
</li>
<li>
<label for="data">Data Required:</label>
<input type="text" name="data" required/>
</li>
<li>
<label for="purpose">Purpose:</label>
<input type="text" name="purpose" required/>
</li>
<li>
<button class="submit" type="submit">Submit</button>
</li>
</ul>
</form>
</body>
</html>
This is the styles.css for the form:
.form {
background-color:#ffffff;
margin: 0 auto;
width:750px;
height: 825px;
}
body {font: 14px/21px "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", sans-serif;}
.form h2, .form label {font-family:Georgia, Times, "Times New Roman", serif;}
.form_hint, .required_notification {font-size: 11px;}
.form ul {
width:750px;
list-style-type:none;
list-style-position:outside;
margin:0px;
padding:0px;
}
.form li{
padding:13px;
border-bottom:1px solid #eee;
position:relative;
}
.form li:first-child, .form li:last-child {
border-bottom:2px solid #777;
}
/*header*/
.form h2 {
margin:0;
display: inline;
}
.required_notification {
color:#d45252;
margin:5px 0 0 0;
display:inline;
float:right;
}
.form label {
width:200px;
margin-top: 3px;
display:inline-block;
float:left;
padding:3px;
}
.form input {
height:20px;
width:220px;
padding:5px 8px;
}
.form textarea {padding:8px; width:300px;}
.form button {margin-left:156px;}
.form input, .form textarea {
border:1px solid #aaa;
box-shadow: 0px 0px 3px #ccc, 0 10px 15px #eee inset;
border-radius:2px;
-moz-transition: padding .25s;
-webkit-transition: padding .25s;
-o-transition: padding .25s;
transition: padding .25s;
padding-right:30px;
}
.form input:focus, .form textarea:focus {
padding-right:70px;
background: #fff;
border:1px solid #555;
box-shadow: 0 0 3px #aaa;
}
button.submit {
margin: 250 auto;
width:100px;
}
button.submit {
background-color: #2F68B1;
background: -webkit-gradient(linear, left top, left bottom, from(#2F68B1), to(#10468B));
background: -webkit-linear-gradient(top, #2F68B1, #10468B);
background: -moz-linear-gradient(top, #2F68B1, #10468B);
background: -ms-linear-gradient(top, #2F68B1, #10468B);
background: -o-linear-gradient(top, #2F68B1, #10468B);
background: linear-gradient(top, #2F68B1, #10468B);
border: 1px solid #2C6BB8;
border-bottom: 1px solid #5b992b;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
-o-border-radius: 3px;
box-shadow: inset 0 1px 0 0 #9fd574;
-webkit-box-shadow: 0 1px 0 0 #9fd574 inset ;
-moz-box-shadow: 0 1px 0 0 #9fd574 inset;
-ms-box-shadow: 0 1px 0 0 #9fd574 inset;
-o-box-shadow: 0 1px 0 0 #9fd574 inset;
color: white;
font-weight: bold;
padding: 7px 20px;
text-align: center;
text-shadow: 0 -1px 0 #396715;
}
button.submit:hover {
opacity:.85;
cursor: pointer;
}
button.submit:active {
border: 1px solid #20911e;
box-shadow: 0 0 10px 5px #356b0b inset;
-webkit-box-shadow:0 0 10px 5px #356b0b inset ;
-moz-box-shadow: 0 0 10px 5px #356b0b inset;
-ms-box-shadow: 0 0 10px 5px #356b0b inset;
-o-box-shadow: 0 0 10px 5px #356b0b inset;
}
input:required, textarea:required {
background: #fff url(asterisk.jpg) no-repeat 98% center;
}
/*invalid, valid*/
.form input:focus:invalid, .form textarea:focus:invalid { /* when a field is considered invalid by the browser */
background: #fff url(invalid.jpg) no-repeat 98% center;
box-shadow: 0 0 5px #d45252;
border-color: #b03535
}
.form input:required:valid, .form textarea:required:valid { /* when a field is considered valid by the browser */
background: #fff url(valid.jpg) no-repeat 98% center;
box-shadow: 0 0 5px #5cd053;
border-color: #28921f;
}
.form_hint {
background: #d45252;
border-radius: 3px 3px 3px 3px;
color: white;
margin-left:8px;
padding: 1px 6px;
}
And the form will be transfered to submit.php (I did the database using mysql). I use wampserver.
<?php
//debug mode
error_reporting(E_ALL);
ini_set('display_errors', 'On');
//to show some error is smthng went wrong
$errors = array();
function connect(){
$connection = mysql_connect(localhost, root, "" ); //I have no idea what the password is. where could I set one?
$db = mysql_select_db(permohonan_data,$connection);
if (!$connection || !$db){
return false;
}
else{
return true;
}
}
echo "first stage";
//will run if user did submit the form
if (!empty($_POST)){
echo "second stage";
//connect sql server:
if (!connect()){
$errors[] = "Can't establish link to MySql server";
}
$name = $_POST['name'];
$position = $_POST['position'];
$unit = $_POST['unit'];
$institute = $_POST['institute'];
$telefon = $_POST['telefon'];
$faks = $_POST['faks'];
$email = $_POST['email'];
$data = $_POST['data'];
$purpose = $_POST['purpose'];
echo "third stage";
//no error til here
if (empty($error)){
//prevent SQL injection
$name = mysql_real_escape_string($name);
$position = mysql_real_escape_string($position);
$unit = mysql_real_escape_string($unit);
$institute = mysql_real_escape_string($institute);
$telefon = mysql_real_escape_string($telefon);
$faks = mysql_real_escape_string($faks);
$email = mysql_real_escape_string($email);
$data = mysql_real_escape_string($data);
$purpose = mysql_real_escape_string($purpose);
}
echo "fourth stage";
//try insert value
$query = "INSERT INTO 'user'
(name,position,unit,institute,telefon,faks,email,data,purpose)
VALUES ('$name', '$position', '$unit', '$institute', '$telefon', '$faks', '$email', '$data', '$purpose')";
if (!mysql_query($query)){
//
//die(mysql_error());
$errors[] = "Can't insert the values";
}
else {
//on success
header('location:C:\wamp\www\FORM\thankyou.php');
}
}
?>
Which the result gives no errors, I've put the reporting error syntax, but also nothing is displayed to the screen. The script are still visual at the page source though. And when I put the echo part, the script just runs until "first stage". It didn't redirect to thankyou.php. What did I do wrong? And how can I connect this to the database? I did the $connect part, but it still vague to me. please help.
This is the thankyou.php:
<html>
<head>
<meta charset="utf-8">
<title>thank you!</title>
<link rel="stylesheet" media="screen" href="stylesphp.css" >
</head>
<body bgcolor="#13b4ff">
<div class="boxed";>
<div id="thankyou" style= "text-align:center; font-size:50px;">THANK YOU</div><br>
Your inquiry has been submitted. Please wait 24 hours. <br>
You will be notify by email.
<p> return to <a class="a" href="http://www.moe.gov.my/en/home" target="_self">main page.</a>
</div>
</body>
</html>
EDIT, thanks to Fred -ii- and Joni Salmi, I have fix the error.
but it shows this instead:
Notice: Undefined index: email in C:\wamp\www\FORM\submit.php on line 39.
this is line 39
$email = $_POST['email'];
As per your original question
$_POST is a "superglobal" and MUST be in uppercase.
You have:
if (!empty($_post)){
Change it to:
if (!empty($_POST)){
That seems to be the most likely part of the problem.
As far as I can tell, the rest of your code seems OK to me, besides the fact that you're using a deprecated mysql_ function.
EDIT
As Joni Salmi pointed out in a comment,
you are using msql_connect which should be mysql_connect
Credit to Joni (Salmi)
Change:
$connection = msql_connect(localhost, root, "" );
missing "y" => ^
to:
$connection = mysql_connect(localhost, root, "" );
Also as per your comment about Undefined index: email error message.
Change this line:
<input type="email" name="name" placeholder="name#something.com"/ required>
to:
<input type="email" name="email" placeholder="name#something.com"/ required>
You had:
<label for="name">Name:</label>
<input type="text" name="name" required />
with the same named input field of name="name" as your email input.
Edit #2
Use backticks instead of quotes for your table name.
You have:
$query = "INSERT INTO 'user'
Use (backticks):
$query = "INSERT INTO `user`
You can even remove the quotes: (but backticks are better)
$query = "INSERT INTO user
RE: Undefined index:
You have incorrectly named the input fied that is to hold the email address in the HTML
<input type="email" name="name" placeholder="name#something.com"/ required>
Change it to
<input type="email" name="email" placeholder="name#something.com"/ required>
Note the name="email"
The names you give the fields in HTML control the fieldnames used in the $_POST array.

Login should be in center of the page

In the below code i have placed the controller.the actual result is ligin is in center position but it is in the bottom.My expected result is login should come in center of the page.pls help me to do this.
Controller:
<html>
<head>
</head>
<title>login_form</title>
<BODY onLoad="noBack();" onpageshow="if (event.persisted) noBack();" onUnload=""><div class="container">
<div class="row">
<div class="span4 logo">
<img src="<?php echo base_url('img/logosl.png'); ?>" style="margin-bottom:7px; margin-top:7px;"/>
</div>
<center ><div id="login_form" >
<h1>Login!</h1>
<form action="<?php echo base_url(); ?>index.php/login/validate_credentials" method="post" >
<input type="text" name="username" required placeholder="username" style="height: 25px;" value="" />
<input type="text" name="password" required placeholder="password" style="height: 25px;" value="" />
<input type="text" name="college_name" required placeholder="college_name" style="height: 25px;" value="" />
<input type="submit" name="submit" value="Login" class="btn-success btn" />
Create Account
</form>
</div></center><!-- end login_form-->
<?php $this->load->view('includes/header'); ?>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/style1.css" />
<?php $this->load->view('includes/footer'); ?>
</body>
</html>
css
body {
background:#FFFFFF;
margin: 0;
padding: 0;
font-family: arial;
}
#login_form {
width: 300px;
background: #f0f0f0 url(../img/login_bg.jpg) repeat-x 0 0;
border: 1px solid white;
margin: 250px auto 0;
padding: 1em;
-moz-border-radius: 3px;
}
h1,h2,h3,h4,h5 {
margin-top: 0;
font-family: arial black, arial;
text-align: center;
}
input[type=text], input[type=password] {
display: block;
margin: 0 0 1em 0;
width: 280px;
border: 5px;
-moz-border-radius: 1px;
-webkit-border-radius: 1px;
padding: 1em;
}
input[type=submit], form a {
border: none;
margin-right: 1em;
padding: 6px;
text-decoration: none;
font-size: 12px;
-moz-border-radius: 4px;
background: #348075;
color: white;
box-shadow: 0 1px 0 white;
-moz-box-shadow: 0 1px 0 white;
-webkit-box-shadow: 0 1px 0 white;
}
input[type=submit]:hover, form a:hover {
background: #287368;
cursor: pointer;
}
/* Validation error messages */
.error {
color: #393939;
font-size: 15px;
}
fieldset {
width: 300px;
margin: auto;
margin-bottom: 2em;
display: block;
}
/* FOR FUN */
h1 {
text-shadow: 0 1px 0 white;
}
/* Not necessary. Just the "tutorial created by" stuff at the bottom */
#tutInfo {
background: #e3e3e3;
border-top: 1px solid white;
position: absolute;
bottom: 0;
width: 100%;
padding: .7em .7em .7em 2em;
}
You are missing < / div>
<div class="row">
<div class="span4 logo">
<img src="<?php echo base_url('img/logosl.png'); ?>" style="margin-bottom:7px; margin-top:7px;"/>
</div>
**</div>**

Categories