Trouble Aligning Columns in Form - php

I'm creating an online form and having a bit of trouble aligning the input boxes in the form. I've tried <br>, but it's always slightly off. I'm assuming this is affecting the text below as well.
Also, is PHPMailer still the preferred(simplest) way to go to retrieve the data user's input and attach? Some files might be pretty large.
head,
body {
font-family: 'Open Sans', sans-serif;
margin: 0;
padding: 0;
}
.header {
background-color: #0C2440;
color: white;
padding-top: 10px;
padding-bottom: 15px;
padding-right: 5px;
}
.header img {
float: left;
padding-top: 10px;
padding-right: 10px;
}
.header h1 {
text-align: center;
margin-right: 110px;
}
h2 {
text-align: center;
}
input[type=text],
select {
width: 80%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=date],
select {
width: 80%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=button] {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=button]:hover {
background-color: #45a049;
}
.column {
width: 50%;
float: left;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Web Mileage Certification Change Request Form</title>
<link rel="stylesheet" href="stylesheet.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,300,600,700,800" media="all" onload="if(media!='all')media='all'">
<script src="jquery-3.4.1.min.js"></script>
<script type="text/javascript">
document.getElementById('date').value = Date();
// document.getElementById('submit').onclick = function () {
// location.href = "confirmation.html";
// return false;
// };
// document.querySelectorAll('a[href^="#"]').forEach(anchor => {
// anchor.addEventListener('click', function (e) {
// e.preventDefault();
// document.querySelector(this.getAttribute('href')).scrollIntoView({
// behavior: 'smooth'
// });
// });
// });
</script>
</head>
<body>
<div class="header">
<img src="logo.png" alt="Logo">
<h1>Planning Department</h1>
</div>
<br>
<h2>Mileage Change Request Form</h2>
<br>
<div class="form">
<form>
<fieldset>
<br>
<div class="column">
Date of Submittal:<br>
<input type="date" id="date" name="date"><br> County Name:<br>
<input type="text" id="county" name="county"><br> City/Town Name:<br>
<input type="text" id="cityname" name="cityname"><br> Name of Office and Title:<br>
<input type="text" id="officename" name="officename"><br> Address:
<br>
<input type="text" id="address" name="address"><br> City:
<br>
<input type="text" id="city" name="city"><br>
</div>
<div class="column">
State:<br>
<input type="text" id="state" name="address"><br> ZIP Code:<br>
<input type="text" id="zip" name="zip"><br> Telephone:
<br>
<input type="text" id="phone" name="phone"><br> Fax:
<br>
<input type="text" id="fax" name="fax"><br> Email:
<br>
<input type="text" id="email" name="email"><br> Comments:
<br>
<input type="text" id="comments" name="comments"><br>
</div>
<div class="reqs">
<br>
<p><b>Before we can make any changes, you MUST include items 1-3 for each submission. For annexations with mileage changes, you MUST include items 1-4. If you only have an annexation with no changes to mileage, item 4 is all you need to submit.</b></p>
<ol>
<li>Copy of a current (scaled) map(s) depicting the roads that need added and/or removed OR a shapefile or file geodatabase. If none of these are available, provide a copy of measurable (Scaled) plats depicting the roads that need added/removed.</li>
<input type="file" id="uploaded_file" name="pic" accept="image/*" required>
<li>Copy of meeting minutes at which a governing body accepted the roads into your system. If unavailable, please provide a letter stating the acceptance of the roads signed by an elected official. An example acceptance letter is available if
needed.</li> <input type="file" name="pic" accept="image/*" required>
<li>A list of each road and its requested mileage.</li> <input id="fileSelect" name="spreadsheet" type="file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" required>
<li>Copy of annexation ordinance(s) establishing the new corporate limits along with a shapefile and/or file geodatabase of the correct corporate limits. If a shapefile is not available provide a drawing of the correct corporate limits on a scaled
map.</li> <input type="file" name="pic" accept="image/*" required>
</ol>
</div>
</fieldset>
</form>
</div>
<input id="submit" type="button" value="Submit"></input>
<!-- <?php
if(isset($_POST['submit'])) {
$emailAddress = '';
require "class.phpmailer.php";
$msg = 'Date:'.$_POST['date'].'<br /> County:'.$_POST['county'].'<br /> City/Town Name:'.$_POST['cityname'].'<br /> Name of Office and Title: '.$_POST['officename']. '<br /> Address: '.$_POST['address']. '<br /> City: '.POST['city'], '<br /> State: $_POST['state']. '<br /> ZIP Code: '.POST['zip']. '<br /> Telephone: '.$_POST['phone']. '<br /> Fax: '.$_POST['fax']. '<br /> Email: '.$_POST['email']. '<br /> Comments: '$_POST['comments']. '<br />';
move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], $_FILES["uploaded_file"]["name"]);
$mail = new PHPMailer();
$mail->IsMail();
$mail->AddReplyTo($_POST['email'], $_POST['name']);
$mail->AddAddress($emailAddress);
$mail->SetFrom($_POST['email'], $_POST['name']);
$mail->Subject = "Subject";
$mail->MsgHTML($msg);
$mail->AddAttachment( $_FILES["uploaded_file"]["name"]);
$mail->Send();
echo'<script> window.location="../MCCR.html"; </script> ';
}
?> -->
</body>
</html>

Remove <br> and use CSS style. Added some style in your existing code as
// newly added style begin
h2 {
text-align: center;
margin:30px 0;
}
fieldset {
padding-top:20px;
}
.form-fields {
display: flex;
flex-direction:row;
width: 80%;
margin: 0 auto;
}
.column {
width:50%;
display:flex;
flex-direction:column;
}
input {
width:100%;
}
//end
head,
body {
font-family: 'Open Sans', sans-serif;
margin: 0;
padding: 0;
}
.header {
background-color: #0C2440;
color: white;
padding-top: 10px;
padding-bottom: 15px;
padding-right: 5px;
}
.header img {
float: left;
padding-top: 10px;
padding-right: 10px;
}
.header h1 {
text-align: center;
margin-right: 110px;
}
input[type=text],
select {
width: 80%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=date],
select {
width: 80%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=button] {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=button]:hover {
background-color: #45a049;
}
// newly added style begin
h2 {
text-align: center;
margin:30px 0;
}
fieldset {
padding-top:20px;
}
.form-fields {
display: flex;
flex-direction:row;
width: 80%;
margin: 0 auto;
}
.column {
width:50%;
display:flex;
flex-direction:column;
}
input {
width:100%;
}
//end
<!DOCTYPE html>
<html lang="en">
<head>
<title>Web Mileage Certification Change Request Form</title>
<link rel="stylesheet" href="stylesheet.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,300,600,700,800" media="all" onload="if(media!='all')media='all'">
<script src="jquery-3.4.1.min.js"></script>
<script type="text/javascript">
//document.getElementById('date').value = Date();
// document.getElementById('submit').onclick = function () {
// location.href = "confirmation.html";
// return false;
// };
// document.querySelectorAll('a[href^="#"]').forEach(anchor => {
// anchor.addEventListener('click', function (e) {
// e.preventDefault();
// document.querySelector(this.getAttribute('href')).scrollIntoView({
// behavior: 'smooth'
// });
// });
// });
</script>
</head>
<body>
<div class="header">
<img src="logo.png" alt="Logo">
<h1>Planning Department</h1>
</div>
<h2>Mileage Change Request Form</h2>
<div class="form">
<form>
<fieldset>
<div class="form-fields">
<div class="column">
Date of Submittal:
<input type="date" id="date" name="date"> County Name:
<input type="text" id="county" name="county"> City/Town Name:
<input type="text" id="cityname" name="cityname"> Name of Office and Title:
<input type="text" id="officename" name="officename"> Address:
<input type="text" id="address" name="address"> City:
<input type="text" id="city" name="city">
</div>
<div class="column">
State:
<input type="text" id="state" name="address"> ZIP Code:
<input type="text" id="zip" name="zip"> Telephone:
<input type="text" id="phone" name="phone"> Fax:
<input type="text" id="fax" name="fax"> Email:
<input type="text" id="email" name="email"> Comments:
<input type="text" id="comments" name="comments">
</div>
</div>
<div class="reqs">
<p><b>Before we can make any changes, you MUST include items 1-3 for each submission. For annexations with mileage changes, you MUST include items 1-4. If you only have an annexation with no changes to mileage, item 4 is all you need to submit.</b></p>
<ol>
<li>Copy of a current (scaled) map(s) depicting the roads that need added and/or removed OR a shapefile or file geodatabase. If none of these are available, provide a copy of measurable (Scaled) plats depicting the roads that need added/removed.</li>
<input type="file" id="uploaded_file" name="pic" accept="image/*" required>
<li>Copy of meeting minutes at which a governing body accepted the roads into your system. If unavailable, please provide a letter stating the acceptance of the roads signed by an elected official. An example acceptance letter is available if
needed.</li> <input type="file" name="pic" accept="image/*" required>
<li>A list of each road and its requested mileage.</li> <input id="fileSelect" name="spreadsheet" type="file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" required>
<li>Copy of annexation ordinance(s) establishing the new corporate limits along with a shapefile and/or file geodatabase of the correct corporate limits. If a shapefile is not available provide a drawing of the correct corporate limits on a scaled
map.</li> <input type="file" name="pic" accept="image/*" required>
</ol>
</div>
</fieldset>
</form>
</div>
<input id="submit" type="button" value="Submit"></input>
<!-- <?php
if(isset($_POST['submit'])) {
$emailAddress = '';
require "class.phpmailer.php";
$msg = 'Date:'.$_POST['date'].'<br /> County:'.$_POST['county'].'<br /> City/Town Name:'.$_POST['cityname'].'<br /> Name of Office and Title: '.$_POST['officename']. '<br /> Address: '.$_POST['address']. '<br /> City: '.POST['city'], '<br /> State: $_POST['state']. '<br /> ZIP Code: '.POST['zip']. '<br /> Telephone: '.$_POST['phone']. '<br /> Fax: '.$_POST['fax']. '<br /> Email: '.$_POST['email']. '<br /> Comments: '$_POST['comments']. '<br />';
move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], $_FILES["uploaded_file"]["name"]);
$mail = new PHPMailer();
$mail->IsMail();
$mail->AddReplyTo($_POST['email'], $_POST['name']);
$mail->AddAddress($emailAddress);
$mail->SetFrom($_POST['email'], $_POST['name']);
$mail->Subject = "Subject";
$mail->MsgHTML($msg);
$mail->AddAttachment( $_FILES["uploaded_file"]["name"]);
$mail->Send();
echo'<script> window.location="../MCCR.html"; </script> ';
}
?> -->
</body>
</html>

Related

Checkbox alignment issues within PHP/HTML form

I am trying to edit a form I have used many times but now I need to add checkboxes for options and I cannot for the life of me get them to align correctly or figure out where the formatting needs to be changed. I am not an expert at PHP, HTML, or CSS I was just tasked with this being in IT so I am learning as I am going. You guys have always came to my rescue on previous projects too and I am about a days worth deep into it with no changes. Made the checkboxes red in the CSS just so I could make sure a change I made to them went.
Basically want the checkboxes to look like this:
Project needs: [] Photography [] Videography [] Resize
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Marketing and Communications Request</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="marketing_style.css" />
</head>
<body>
<center>
<br /><br /><img src="logo.jpg" width="350px" height"100px"><br /><br />
<H1>Marketing and Communications Request</H1>
</center>
<div id="page-wrap">
<div id="contact-area">
<br />
<br />
<form method="post" action="marketing_contactengine.php">
<label for="Name">Name:</label>
<input type="text" name="Name" id="Name" />
<label for="Email">Email:</label>
<input type="text" name="Email" id="Email" />
<label for="Phone">Phone:</label>
<input type="text" name="Phone" id="Phone" />
<label for="Dept">Department:</label>
<input type="text" name="Dept" id="Dept" />
<label for="Dir">Department Director:</label>
<input type="text" name="Dir" id="Dir" />
<label for="COID">COID/Account Code (GL Code):</label>
<input type="text" name="COID" id="COID" />
<br><br>
<br><br>
<h2><u>EVENT INFORMATION</u></h2>
<label for="EventName">Event Name:</label>
<input type="text" name="EventName" id="EventName" />
<label for="EventDateTime">Event Date & Time:</label>
<input type="text" name="EventDateTime" id="EventDateTime" placeholder="01/01/2021 08:00:00" />
<label for="EventLocation">Event Location:</label>
<input type="text" name="EventLocation" id="EventLocation" />
<label for="Desc">Brief description of the event:</label><br />
<textarea name="Desc" rows="2" cols="10" id="Desc"></textarea>
<br><br>
<br><br>
<h2><u>PROJECT INFORMATION</u></h2>
<label for="ProjectName">Project Name:</label>
<input type="text" name="ProjectName" id="ProjectName" />
<label for="Materials">Materials due date:</label>
<input type="text" name="Materials" id="Materials" />
<br />
</div>
<div id="checkboxes" class="checkboxes">
<label id="ProjectNeeds" for="ProjectNeeds" class="checkboxes">Project needs (check all that apply):</label>
<label class="checkboxes" for="Photography"><input type="checkbox" id="Photography" /> <span>Photography</span></label>
<label class="checkboxes" for="Videography"><input type="checkbox" id="Videography" /> <span>Videography</span></label>
<label class="checkboxes" for="Resize"><input type="checkbox" id="Resize" /> <span>Resize</span></label>
</div>
</div>
</div>
<div id="bottom" style="position: relative;">
<div style="position: absolute;">
Submission of this form is required for all requests to the marketing and communications team.
</div>
</body>
</html>
CSS:
body {
font-size: 62.5%;
font-family: Helvetica, sans-serif;
}
p {
font-size: 1.3em;
margin-bottom: 15px;
}
#page-wrap {
background: white;
padding: 20px 50px 20px 50px;
min-height: 500px;
height: auto !important;
height: 500px;
width: 700px;
}
#contact-area {
width: 660px;
margin-top: 25px;
}
#contact-area input, #contact-area textarea {
padding: 10px;
width: 471px;
font-family: Helvetica, sans-serif;
font-size: 1.4em;
margin: 0px 0px 10px 0px;
/* border: 2px solid #ccc; */
}
/* #contact-area textarea { */
/* height: 90px; */
/* } */
#contact-area textarea:focus, #contact-area input:focus {
border: 2px solid #900;
}
#contact-area input.submit-button {
width: 100px;
float: right;
}
label {
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
padding-top: 10px;
font-size: 1.4em;
font-weight: bold;
}
#bottom {
font-family: Helvetica, sans-serif;
font-size: 1.4em;
margin: 0px 0px 0px 100px;
width: 900px;
padding-top: 75px;
padding-bottom: 75px;
text-align: left;
}
#checkboxes {
color: red;
}
In your CSS, you have a label {} declaration that is affecting all labels, including the ones next to your input radios. It is making them float and that's why they mess up.
To fix it you need to add another declaration that cancels the float for the labels inside #checkboxes, like so:
#checkboxes label {
float: none;
}
You have to set the label CSS properties like that:
label {
float: left;
text-align: right;
margin-right: 15px;
padding-top: 10px;
font-size: 1.4em;
font-weight: bold;
}
And add another CSS line:
.checkboxes input { float:left; vertical-align:middle; margin-right:10px; }

Why does my form submit an empty string to php file in ie but not chrome or mozilla?

My goal is, when somebody fills out the form, for the information to be submitted on click of the submit button, to the php file, which in turn will email me with the form values. It works in chrome and mozilla apparently, but not in Edge or Safari. I've searched everywhere for an answer but I can't find anything. What am I not including? Did I code it wrong? I just cannot figure it out.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type= "text/css" href="PMOM.css">
<link href="https://fonts.googleapis.com/css?family=Arimo|Fira+Sans|Muli|Nunito|Open+Sans|Roboto+Condensed|Ubuntu" rel="stylesheet">
<title>Photo Mirror of Memories</title>
<style>
h1{
text-align: center;
color: white;
}
.main{
padding-top: 80px;
height: 1500px;
width: 100%;
background-color: rgb(82, 117, 139);
}
.main_form{
margin: 0 auto;
padding: 100px 200px;
margin-top: 50px;
height: 700px;
width: 800px;
background-color: white;
border-radius: 15px;
}
.type-field{
width: 400px;
height: 40px;
margin-bottom: 10px;
}
.package-select{
margin-bottom: 8px;
}
.comments{
width: 400px;
height: 40px;
margin: 10px 0;
}
#media (max-width: 600px) {
.main{
color: white;
}
.main_form{
width: 50%;
height: 200px;
background-color: inherit;
padding: 0px;
/* border: 1px solid red; */
}
.type-field{
width: 200px;
height: 40px;
margin-bottom: 10px;
/* border: 1px solid red; */
}
.comments{
width: 200px;
/* border: 1px solid red; */
height: 40px;
margin: 10px 0;
}
}
</style>
</head>
<body>
<div class="main">
<h1 style="color: white;">Please fill out your information</h1>
<div class="main_form">
<form method="post" action="/emailSending.php">
<input class="type-field" type="text" name="fname" placeholder="First Name"><br>
<input class="type-field" type="text" name="lname" placeholder="Last Name"><br>
<input class="type-field" type="text" name="email" placeholder="Email"><br>
<input class="type-field" type="text" name="phone" placeholder="Phone Number"><br>
<input class="package-select" type="radio" name="package" value="Basic" checked> Basic Package
<br>
<input class="package-select" type="radio" name="package" value="Deluxe"> Deluxe Package
<br>
<input class="package-select" type="radio" name="package" value="Premium"> Premium Package
<br>
<input class="comments" type="text-field" name="notes" placeholder="Comments">
<button type="submit" name="button" value="Submit">Submit</button>
</form>
</div>
</div>
<!-- <div id="app2"></div> -->
<script src="/dist/build.js"></script>
</body>
</html>
<?php
$fname=$_POST[fname];
$lname=$_POST[lname];
$email=$_POST[email];
$phone=$_POST[phone];
$package=$_POST[package];
$comments=$_POST[comments];
$to='email#email.com';
$subject="Customer Package";
$message="Name: ".$fname."\n"."Last name: ".$lname."\n"."Email: ".$email."\n"."Phone number: ".$phone."\n"."Package: ".$package;
$headers="From: ".$email;
mail($to, $subject, $message, $headers);
echo "<h1>Thank you</h1>"
?>
For starters, your PHP variables are wrong. Note that I added single quotes to your post elements. I'm not sure how that could possibly be working with any browser.
Other than what I did below, I see no reason at all that it wouldn't work with any browser.
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$package=$_POST['package'];
$comments=$_POST['comments'];

Can't align <div> in center and can't manage opacity properly

Please have a look at the image and the code below. I am making simple signup html form. I am trying to keep in middle of the screen. also I just want to make div background opacity 50% but somehow, text input's and button's opacity is also changed to 50%.
Please help me to find a solution.
Here's a code of a simple signup form.
<!DOCTYPE html>
<html>
<head>
<title>Sign Up</title>
</head>
<body background="back.jpg">
<form>
<div style="background-color: rgb(255,255,255); opacity: 0.5; display: inline-table; padding: 20px; border-radius: 25px;">
<input type="email" name="email" placeholder="Enter your E-Mail here" style="border-radius: 25px; padding: 5px; outline-style: none;"><br><br>
<input type="password" name="password" placeholder="Enter Password" style="border-radius: 25px; padding: 5px; outline-style: none;"><br>
<p style="color: rgb(58,58,58);"><input type="checkbox" name="tnc"> Accept T&C</p>
<input type="submit" name="submit" value="Sign Up" onclick="submit" style="border-radius: 25px; padding: 5px; width: 150px; outline-style: none;">
</div>
</form>
</body>
</html>
See Output of the code above
Please explain or answer deeply. Thanks in advance
just use this color code for the div if you want to make its opacity 50% only<div style="background-color: rgb(255,255,255,.5); opacity: 0.5; display: inline-table; padding: 20px; border-radius: 25px;">and then you dont have to use the opacity for the div.
first give some width to your formform{width:600px;margin:auto; display:block; }it will makes your form in center.
to give margin from top and bottom give style like thisform{margin:150px auto;} so it will also give margin from top-bottom.
Try this your code will be run
<!DOCTYPE html>
<html>
<head>
<title>Sign Up</title>
</head>
<body background="back.jpg">
<form>
<div style="background-color: rgba(255,255,255, .5); display: table; padding: 20px; border-radius: 25px; margin: 0px auto; text-align: center; top: 50%; left:50%; position: absolute; transform: translate(-50%, -50%)">
<input type="email" name="email" placeholder="Enter your E-Mail here" style="border-radius: 25px; padding: 5px; outline-style: none; background: #fff;"><br><br>
<input type="password" name="password" placeholder="Enter Password" style="border-radius: 25px; padding: 5px; outline-style: none;"><br>
<p style="color: rgb(58,58,58);"><input type="checkbox" name="tnc"> Accept T&C</p>
<input type="submit" name="submit" value="Sign Up" onclick="submit" style="border-radius: 25px; padding: 5px; width: 150px; outline-style: none;">
</div>
</form>
</body>
</html>
show code bellow:
body {
text-align: center;
}
form {
display: inline-block;
}
<html>
<head>
<title>Sign Up</title>
</head>
<body background="back.jpg">
<form>
<div style="background-color: rgb(255,255,255,0.5);display: inline-table; padding: 20px; border-radius: 25px;">
<input type="email" name="email" placeholder="Enter your E-Mail here" style="border-radius: 25px; padding: 5px; outline-style: none;"><br><br>
<input type="password" name="password" placeholder="Enter Password" style="border-radius: 25px; padding: 5px; outline-style: none;"><br>
<p style="color: rgb(58,58,58);"><input type="checkbox" name="tnc"> Accept T&C</p>
<input type="submit" name="submit" value="Sign Up" onclick="submit" style="border-radius: 25px; padding: 5px; width: 150px; outline-style: none;">
</div>
</form>
</body>
</html>
I have prepared a snippet for you, using the display: table(-X) properties:
<!DOCTYPE html>
<html>
<head>
<title>Sign Up</title>
</head>
<body background="back.jpg">
<div style="display:table; height:calc(100vh - 50px); width:100%;"><!-- Change the "-50px" part to whatever size your navbar is -->
<div style="display:table-row;">
<div style="display: table-cell; vertical-align:middle; text-align:center;">
<form style="margin:auto;">
<div style="background-color: rgb(255,255,255); opacity: 0.5; padding: 20px; border-radius: 25px;">
<input type="email" name="email" placeholder="Enter your E-Mail here" style="border-radius: 25px; padding: 5px; outline-style: none;"><br><br>
<input type="password" name="password" placeholder="Enter Password" style="border-radius: 25px; padding: 5px; outline-style: none;"><br>
<p style="color: rgb(58,58,58);"><input type="checkbox" name="tnc"> Accept T&C</p>
<input type="submit" name="submit" value="Sign Up" onclick="submit" style="border-radius: 25px; padding: 5px; width: 150px; outline-style: none;">
</div>
</form>
</div>
</div>
</div>
</body>
</html>
Hope this helps!

how to block users who log in without registration to php and database

<!DOCTYPE html>
<?php
session_start();
error_reporting(0);
$submit=$_POST['submit'];
$firstName=strip_tags($_POST['firstName']);
$lastName=strip_tags($_POST['lastName']);
$email=strip_tags($_POST['email']);
$username=strip_tags($_POST['username']);
$password=strip_tags($_POST['password']);
$DateTime=strip_tags($_POST['DateTime']);
if ($submit)
{
//open Database
$connect = mysql_connect("localhost", "root", "");
mysql_select_db("mitch");
//select database
$namecheck = mysql_query ("SELECT username FROM tbmitch WHERE username='$username'");
$count = mysql_num_rows($namecheck);
if ($count!=0)
{
echo "<script type='text/javascript'>alert('Control number already exists')</script>";
}
//check for existence
else
if($username)
{
$queryreg = mysql_query("INSERT INTO tbmitch VALUES ('$username','$lastName','$firstName','$email','$password',now())");
$_SESSION['username']=$username;
header('location:home.php');
echo '
<script type="text/javascript">alert("Record/s saved.");
window.location.href = "home.php";
</script>';
}
else
echo "<script type='text/javascript'>alert('Please fill in all fields')</script>";
}
?>
<html>
<head>
<title>MobileApp-SignUp</title>
<body>
<link rel="stylesheet" type="text/css" href="css/960_12_col.css" />
<style>
* {
font-family: Georgia;
color: black;
text-align: top;
font-size: 16px;}
li {
display: inline;
padding: 5px;}
ul {
position: fixed;
top: 0px;
left: 0px;
padding: 15px;
margin: 0px;
width: 100%;
color: #b5c1ad;
text-align: left;
text-decoration: none;
background: #4EE2EC;}
a {
color: black;
text-decoration: none;}
a:hover {
color: #ffffff;}
header {
text-align: right;}
</style>
<meta name=viewport content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/form.css" />
<script type="text/javascript">
function formatTextArea(textArea) {
textArea.value = textArea.value.replace(/(^|\r\n|\n)([^*]|$)/g, "$1*$2");
}
window.onload = function() {
var textArea = document.getElementByusername("t");
textArea.onkeyup = function(evt) {
evt = evt || window.event;
if (evt.keyCode == 13) {
formatTextArea(this);
}
};
};
</script>
</head>
<center>
<br>
<br>
<br>
<br>
<br>
<br>
<div class="container_12 clearfix">
<div username="header" class="grusername_12">
<img src = "images/img.gif" height="200" width="200" border="3" align="center"></p>
<div username="nav" style="width:450">
<ul>
<li>Back to Home|</li>
<br>
<br>
<img src="images/header.gif" width="95" class="logo" /><br>
<img src="images/underheader.gif" width="75" class="logo" />
</ul>
</div>
</div>
<span class="right">
<?php echo " Welcome ".$_SESSION['UserID']." |"; ?>
</span>
</head>
</body>
<br>
<style type="text/css">
body {
background-image: url("bg/bgcloud.jpeg");
background-repeat: no-repeat;
background-attachment: fixed;
color: black;
padding: 20px;
font-family: Georgia;}
p {
padding: 5px;
margin: 0px;
color: red;}
p.ab {
color: black;}
.button {
padding: 7px 20px;
font-size: 24px;
text-align: center;
cursor: pointer;
outline: none;
color: #fff;
background-color: #7FE817;
border: none;
border-radius: 8px;
box-shadow: 0 5px #999;}
.button:hover {
background-color: #ffffff;}
</style>
<body>
<p class = "ab">[Signup to check your Cacao plant]</p>
<p class = "ab">Signup here <p>&#8595 ↓ ↓ ↓ ↓ ↓</p>
<br>
<br>
<form action="done.php" method="post">
<div>
<label for="name" class="title">First Name:</label>
<input type="text" username="firstName" name="firstNamename" size="30" name='firstName' maxlength="100" required="required"/>
</div>
<br>
<div>
<label for="name" class="title">Last Name:</label>
<input type="text" username="lastName" name="lastName" size="30" name='lastName' maxlength="100" required="required"/>
</div>
<br>
<div>
<label for="email" class="title">E-mail add:</label>
<input type="email" username="email" name="email" size="30" name='email' maxlength="100" required="required"/>
</div>
<br>
<div class="radio-buttons">
<span class="title" required="required">Gender:</span>
<input type="radio" name="gender" username="male" value="M" />
<label for="male">M</label>
<input type="radio" name="gender" username="female" value="F" />
<label for="female">F</label><br />
</div>
<br>
<br>
<div>
<p>*the next entry must be remembered for logging in*</p>
<label for="username">Username:</label>
<input type="text" name="username" required="required" size="20" name='username' maxlength="100"/></title><br />
<br>
<label for="password">Password :</label>
<input type="password" name="password" required="required" size="20" name='password' maxlength="100" />
<br>
<br>
<button class="button"><span>Submit</span></button>
</div>
</form>
</body>
<br>
<br>
<br>
<br>
<br>
<p class = "ab" align="right">
© 2017 BSCT-2B MobileApp
</p>
</form>
</center>
</body>
</html>
I'm into PHP and I find it difficult to pass my files to mysql database (I'm using the xampp here, if that helps), I want to do signups on my site and later log in to the registered data, if I;m referring to other users I want to block users who haven't register themselves on the database first, so how do I do it? What to change?
In PHP + mySql based application we can have web pages for authenticated users only, and to achieve that we need to do following steps:
Create Login Form.
On submit validate the data submitted through form and if it return true (Valid login credential). Create a $_SESSION variable to identify logged in user.
While rendering any webpage which requires authenticated user only, check for that particular $_SESSION variable.
It valid $_SESSION exists, show the page, else redirect it to the login page.
Hope this helps.

Div tag does not contain content

I've created a form that enters comments onto my blog posts but when the comments are displayed on the webpage the background color that I added to the div is either to big or to small. I've provided the code below. Any help is appreciated!
<h2 id="comments-title">Comments</h2>
<div id="comment-list">
<?php
}
$commenttimestamp = strtotime("now");
$sql = "SELECT * FROM php_blog_comments WHERE entry='$id' ORDER BY timestamp";
$result = mysql_query ($sql) or print ("Can't select comments from table php_blog_comments.<br />" . $sql . "<br />" . mysql_error());
while($row = mysql_fetch_array($result)) {
$timestamp = date("l F d Y", $row['timestamp']);
printf("<div class='comment-ind'><p id='comments'><a id='username' href=\"%s\">%s</a> %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp);
print("<p class='comments'>" . stripslashes($row['comment']) . "</p><div class='clr'><br></div></div>");
}
?>
<form id="commentform" method="post" action="process.php">
<p><input type="hidden" name="entry" id="entry" value="<?php echo $id; ?>" />
<input type="hidden" name="timestamp" id="timestamp" value="<?php echo $commenttimestamp; ?>">
<input type="text" name="name" id="name" title="Name (required)" /><br />
<input type="text" name="email" id="email" title="Mail (will not be published) (required)" /><br />
<input type="text" name="url" id="url" title="Website" value="http://" /><br />
<br />
<textarea title="Your Comment Goes Here" name="comment" id="comment"></textarea></p>
<p><input type="submit" name="submit_comment" id="submit_comment" value="Add Comment" /></p>
</form>
</div>
CSS:
#comments-title {
background-color: #282828;
width: 567px;
height: 30px;
font-size: 25px;
font-family: arial;
color: #ffffff;
padding: 5px;
padding-top: 6px;
padding-bottom: 4px;
}
#comment-list{
border:1px solid #dadada;
width: 565px;
padding: 5px;
font-family: Helvetica;
font-size: 18px;
}
#comments {
width: 480px;
font-size: 12px;
color: #444444;
}
.comments {
width: 480px;
height: 20px;
}
.comment-ind {
background-color: #eeeeee;
width: 548px;
position: relative;
min-height: 10px;
margin: 5px;
padding: 8px;
}
Image:
Your problem is with height: 20px;. You can change it to min-height: 20px; and then it will be at least that height, but the way you have it, it will always be 20px tall regardless of the content.
Are we seeing the whole css that applies to this div. Looking at the screen shot I would guess that the paragraph of text is floated left and the containing div is not wrapping. Try removing the height and adding overflow:hidden to the containing .comments div. That way the height will adjust with the size of the contain.

Categories