PHP Contact Page Works but Shows Value Code - php

I have a .php contact page that works and sends the information from the form to my email, but it also shows {value=""} in two places on my form.
Am I missing "
The code is as follows:
<?php
<form method="post" action="#contact" role="form">
<div class="form-inline">
<div class="col-md-9 form-group">
<label for="name">your name</label>
<span class="fieldSpan">
<input type="text"
input pattern=".{5,}"
required title="5 characters minimum"
name="name"
id="input-field-name"
class="form-control"
>
value="<?php echo $_POST['name']; ?>"
</div>
</div>
</div>
<div class="form-inline">
<div class="col-md-9 form-group">
<label for="email">your email address</label>
<span class="fieldSpan">
<input type="email"
name="email"
id="input-field-email"
input pattern=".{6,}"
required title="6 characters minimum"
class="form-control"
>
value="<?php echo $_POST['email'];?>"
</div>
</div>
</div>

Here your error
id="input-field-name"
class="form-control"
>
value="<?php echo $_POST['name']; ?>"
</div>
you put value=".... after the closing > of the input

Use code as follows.Input value always in tag
<form method="post" action="#contact" role="form">
<div class="form-inline">
<div class="col-md-9 form-group">
<label for="name">your name</label>
<span class="fieldSpan">
<input type="text"
input pattern=".{5,}"
required title="5 characters minimum"
name="name"
id="input-field-name"
class="form-control"
value="<?php echo $_POST['name']; ?>"
>
</div>
</div>
</div>
<div class="form-inline">
<div class="col-md-9 form-group">
<label for="email">your email address</label>
<span class="fieldSpan">
<input type="email"
name="email"
id="input-field-email"
input pattern=".{6,}"
required title="6 characters minimum"
class="form-control"
value="<?php echo $_POST['email'];?>"
>
</div>
</div>
</div>

Related

Pop up contact form disappears when clicking the submit button

The form is based on bootstrap here is the code:
When i try to validate the submition of the for using this very simple code.
Then the form just disappears. Any insights guys would be greatly appreciated.
Thanks
New gal to coding.
<div class="container">
<div class="row">
<div class="col-sm-12 contact-form">
<form id="contact" method="post" class="form" role="form">
<div class="row">
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="name" placeholder="FIRST NAME" type="text" required autofocus />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="lastname" placeholder="LAST NAME" type="text" required
autofocus />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="email" name="email" placeholder="EMAIL" type="email" required />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="phone" placeholder="PHONE" type="text" required autofocus />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="address1" placeholder="ADDRESS 1" type="text" required
autofocus />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="address2" placeholder="ADDRESS 2" type="text" required
autofocus />
</div>
<div class="col-xs-6 col-md-6 form-group">
<input class="form-control" id="name" name="city" placeholder="CITY" type="text" required autofocus />
</div>
<div class="col-xs-3 col-md-3 form-group">
<input class="form-control" id="name" name="state" placeholder="STATE" type="text" required autofocus />
</div>
<div class="col-xs-3 col-md-3 form-group">
<input class="form-control" id="name" name="zipcode" placeholder="ZIPCODE" type="text" required autofocus />
</div>
<h1 class="h1-contact">WHAT SERVICES ARE YOU INTERESTED IN?</h1>
</div>
<div class="row">
<div class="col-sm-6">
<h3>SELECT ALL THAT APPLY:</h3>
<label class="checkbtn">item 1
<input type="checkbox" checked="checked" name="item5" value="item5">
<span class="checkmark"></span>
</label>
<label class="checkbtn"> item 2
<input type="checkbox" name="item4" id="item4">
<span class="checkmark"></span>
</label>
<label class="checkbtn">item 3
<input type="checkbox" name="item3" id="item3">
<span class="checkmark"></span>
</label>
<label class="checkbtn">item 4
<input type="checkbox" name="item2" id="item2">
<span class="checkmark"></span>
</label>
<label class="checkbtn">item 5
<input type="checkbox" name="example1">
<span class="checkmark"></span>

How to send data to database using form tag?

I can send data to database but using tag. I want to use tag so that the validation in my page will show like "please enter a valid email-address", "password do not match" and many more.
The problem is when I use tag it shows no validation but the data send to db.
But if use tag it shows the validation, but the data is not entering into db.
Here is the view code:
<div class="form-horizontal" id="block-validate">
<?php echo form_open(base_url("index.php/main/editClass"));?>
<div class="form-group">
<label class="control-label col-lg-2"><b>
Course Code-Section
</b></label>
<div class="col-lg-4">
<input class="form-control" name="ccs" type="text" value="<?php echo $Course_Code_Section;?>">
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2"><b>
Course Description
</b></label>
<div class="col-lg-4">
<input class="form-control" name="des" type="text" value="<?php echo $Description;?>">
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2"><b>
School Year-Semester
</b></label>
<div class="col-lg-4">
<input class="form-control" name="sys" type="text" value="<?php echo $School_Year_Semester;?>">
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2"><b>
Room
</b></label>
<div class="col-lg-4">
<input class="form-control" name="rm" type="text" value="<?php echo $Room;?>">
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2"><b>
Day-Time
</b></label>
<div class="col-lg-4">
<input class="form-control" name="dt" type="text" value="<?php echo $Day_Time;?>">
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-2"><b>
Student
</b></label>
<div class="col-lg-4">
<input class="form-control" name="stu" type="text" value="<?php echo $Student;?>">
</div>
</div>
<div class="form-actions">
<input type="hidden" name="id" value="<?php echo $CID;?>">
<label class="control-label col-lg-2"></label>
<button type="submit" class="btn btn-primary btn-grad btn-rect">Submit</button>
Cancel
</div>
<?php echo form_close();?>
</div>
Here is the code that I am changing:
<div class="form-horizontal" id="block-validate">
And I changed it to:
<form class="form-horizontal" id="block-validate">
When I use the form tag, the url shows this:
http://localhost/ams/index.php/main/showEditClassView?ccs=CPE+506-CPE42FA1&des=Software+Engineering&sys=SY+2016-2017+2nd+Sem&rm=A-225&dt=Saturday-07%3A30+AM-12%3A30+PM&stu=Ronnel+Gonzales&id=1
What if you modify:
<div class="form-horizontal" id="block-validate">
<?php echo form_open(base_url("index.php/main/editClass"));?>
to:
<div class="form-horizontal">
<?php echo form_open(base_url("index.php/main/editClass"), 'id="block-validate"');?>
So that Codeigniter opens the form tag for you, but we use id="block-validate" so your validation can run?
Use method="POST" if you do not want to appear the values in the url.Hope this will sort your problem.
<form class="form-horizontal" id="block-validate" method="POST">

How to get bootstrap contact form working with php?

I want to add a contact form on my page but I've never worked with PHP before. I need help, please?
I'm working with the form below:
<a name="Contact"></a>
<div class="contact">
<div class="container">
<div class="row">
<div class="col-lg-8">
<h1 class="page-header text-center">Get in touch!</h1>
<form class="form-horizontal" role="form" method="post" action="index.php">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name" name="name" placeholder="First & Last Name" value="<?php echo htmlspecialchars($_POST['name']); ?>">
<?php echo "<p class='text-danger'>$errName</p>";?>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" name="email" placeholder="example#domain.com" value="<?php echo htmlspecialchars($_POST['email']); ?>">
<?php echo "<p class='text-danger'>$errEmail</p>";?>
</div>
</div>
<div class="form-group">
<label for="message" class="col-sm-2 control-label">Message</label>
<div class="col-sm-10">
<textarea class="form-control" rows="4" name="message"><?php echo htmlspecialchars($_POST['message']);?></textarea>
<?php echo "<p class='text-danger'>$errMessage</p>";?>
</div>
</div>
<div class="form-group">
<label for="human" class="col-sm-2 control-label">2 + 3 = ?</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="human" name="human" placeholder="Your Answer">
<?php echo "<p class='text-danger'>$errHuman</p>";?>
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-sm-offset-2">
<?php echo $result; ?>
</div>
</div>
</form>
</div>
For for some reason, it's not displaying properly. This is how it looks:
screenshot of contact form

PHP not receiving data from HTML5 form

I am recently getting into php and am running it locally on Xampp. I have created the following simple form followed by a few lines of php. It seems that no data is being passed through from the html form to the php page.
<form method="post" action="emailform.php" enctype="text/plain" class="form-horizontal">
<div class="row input">
<div class="col-md-1"></div>
<div class="col-md-10">
<div class="form-group">
<input type="text" name="subject" id="subject" class="form-control" placeholder="subject">
</div>
</div>
</div>
<div class="row input">
<div class="col-md-1"></div>
<div class="col-md-4">
<div class="form-group">
<input type="text" name="name" id="name" class="form-control" placeholder="full name">
</div>
<div class="form-group">
<input type="email" name="subject" id="email" class="form-control" placeholder="email">
</div>
</div>
<div class="col-md-1"></div>
<div class="col-md-5 textarea">
<textarea class="form-control" name="message" id="message" rows="4" placeholder="message"></textarea>
</div>
</div>
<br>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-10">
<button type="submit" class="btn" id="submit">Send</button>
</div>
</div>
</form>
This is the simple php code I am using to test:
<?php
$subject = 'No subject was set';
if (isset($_POST['subject'])) {
$subject = ($_POST['subject']);
}
echo "This is the subject:$subject";
?>
I appreciate any help as I have been struggling with this simple code for the past week now.
Two subject names!
<input type="email" name="subject" id="email" class="form-control" placeholder="email">
^
and
<input type="text" name="subject" id="subject" class="form-control" placeholder="subject">
^
Also remove enctype="text/plain" from the form
It's because PHP doesn't handle it

Submit button will not send form data to MySQL database [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have a problem that might be a syntax problem but I can't seem to figure out what I am doing wrong.
I have created a form and when I click on submit, the data in the form is not sent to my mysql database.
Here is my html code
<div class="content-wrapper">
<div class="container">
<div class="row">
<div class="col-md-10">
<h1 class="page-head-line">Forms </h1>
</div>
</div>
<div class="row">
<div class="col-md-10">
<div class="panel panel-default">
<div class="panel-heading">
BASIC FORM ELEMENTS
</div>
<div class="panel-body">
<form method="post" action="insert.php" >
<div class="form-group">
<label for="name">Name</label>
<input name="name' type="text" class="form-control" id="name" placeholder="Enter your name" required/>
</div>
<div class="form-group">
<label for="project_num">OIT-GIS Project Number</label>
<input name="project_num' type="text" class="form-control" id="project_num" placeholder="OIT-GIS Project Number" />
</div>
<div class="form-group">
<label for="project_name">Project Name</label>
<input name="name' type="text" class="form-control" id="project_name" placeholder="Project Name" required/>
</div>
<div class="form-group">
<label for="easyvista">EasyVista Ticket Number</label>
<input name="easyvista' type="text" class="form-control" id="easyvista" placeholder="EasyVista Ticket Number" />
</div>
<div class="form-group">
<label for="agency">Requestor/Agency</label>
<input name="agency' type="text" class="form-control" id="agency" placeholder="Requestor or Agency" />
</div>
<div class="form-group">
<label for="description">Description of Work:</label>
<input name="description' type="text" class="form-control" id="agency" placeholder="Description" />
</div>
<div class="form-group">
<label for="input-date">Enter Today Date</label>
<input name="input-date' type="date" value="">
<span class="result"></span>
</div>
<div class="form-group">
<div class="col-md-10">
<input id="submit" name="submit" type="submit" class="btn btn-primary">
</div>
</div>
</form>
</div>
</div>
and here is my php
<?php
echo $POST;
error_reporting(E_ALL);
ini_set('display_errors', 1);
include("../includes/config.php");
if (isset($_POST['submit'])) {
echo $_POST['submit'];
$name = $_POST['name'];
$projectnum = $_POST['project_num'];
$projectname = $_POST['project_name'];
$easyvista = $_POST['easyvista'];
$agency = $_POST['agency'];
$description = $_POST['description'];
$startDate = $_POST['input-date'];
$sql="INSERT INTO statusreport(name, project_num, project_name, easyvista, agency, description)
VALUES
('$name','$projectnum', '$projectname', '$easyvista', '$agency', '$description')";
if (!mysqli_query($conn, $sql))
{
die('Error: ' . mysqli_connect_error($conn));
}
echo "Entry is recored <br/>";
echo "Name:", $name, "<br/>";
echo "test..................<br/>", $name;
/*header("location: http://10.1.7.129//gisadmin/admin/forms.php");*/
//echo "<script>setTimeout(\"location.href = 'http://10.1.7.129//gisadmin/admin/forms.php';\",700);</script>";
mysqli_query($conn, $sql);
}
else {
echo "No data";
}
?>
Any help would be greatly appreciated.
Thanks
You have a mixing of single and double quotes here, the name attributes are opening the value with double quotes and closing with single quotes, should be as follows:
<form method="post" action="insert.php" >
<div class="form-group">
<label for="name">Name</label>
<input name="name" type="text" class="form-control" id="name" placeholder="Enter your name" required/>
</div>
<div class="form-group">
<label for="project_num">OIT-GIS Project Number</label>
<input name="project_num" type="text" class="form-control" id="project_num" placeholder="OIT-GIS Project Number" />
</div>
<div class="form-group">
<label for="project_name">Project Name</label>
<input name="project_name" type="text" class="form-control" id="project_name" placeholder="Project Name" required/>
</div>
<div class="form-group">
<label for="easyvista">EasyVista Ticket Number</label>
<input name="easyvista" type="text" class="form-control" id="easyvista" placeholder="EasyVista Ticket Number" />
</div>
<div class="form-group">
<label for="agency">Requestor/Agency</label>
<input name="agency" type="text" class="form-control" id="agency" placeholder="Requestor or Agency" />
</div>
<div class="form-group">
<label for="description">Description of Work:</label>
<input name="description" type="text" class="form-control" id="agency" placeholder="Description" />
</div>
<div class="form-group">
<label for="input-date">Enter Today Date</label>
<input name="input-date" type="date" value="">
<span class="result"></span>
</div>
<div class="form-group">
<div class="col-md-10">
<input id="submit" name="submit" type="submit" class="btn btn-primary">
</div>
</div>
</form>
And then, as #Fred -ii stated in his comment, the php script is wrong:
echo $POST;
That line is wrong, there is no variable with name $POST before that code.
Are you getting success message but database is not getting updated OR Getting Total Error...???
1) Check for double quotes and single quotes..
<div class="form-group">
<label for="name">Name</label>
<input name="name" type="text" class="form-control" id="name" placeholder="Enter your name" required/>
</div>
2) Also check for path... for
include("../includes/config.php");
Is it correct or not...?
3)
<label for="project_name">Project Name</label>
<input name="name' type="text"
SHOULD BE
<label for="project_name">Project Name</label>
<input name="project_name" type="text"

Categories