My form fields have space in them, if I select and delete this space my prefilled text shows back up. I don't know what to make of this and have been trouble shooting all day. Any ideas? Here is my code...
<?php
include '_include/php/header.php';
#set variables to be used in the header
$page_title = "Assesment";
?>
<div class="page" id="subheader">
<div class="container">
<!-- Title Page -->
<div class="row">
<div class="span12">
<div class="title-page">
<h2 class="title">Four simple steps...</h2>
<h3 class="title-description">To dictate what you need
in a website</h3>
</div>
</div>
</div><!-- End Title Page -->
<!-- submenu -->
<?php
include '_include/php/submenu.php'; ?>
</div>
</div><!-- End sub header -->
<!-- main Section -->
<div class="page" id="contact">
<div class="container">
<!-- Title Page -->
<div class="row">
<div class="span12">
<div class="title-page">
<h2 class="title">Assesment - Step One</h2>
<h3 class="title-description">Status: <span class=
"color-text"><?php echo $assessresult; ?></span></h3>
</div>
</div>
</div><!-- End Title Page -->
<!-- main Form -->
<div class="row">
<div class="span9">
<form action="assessment_submitted.php" class="contact-form" id="contact-form"
method="post" name="contact-form">
<h3 class="color-text">What do you wish to get out of
your website?</h3>
<p class="contact-message">
<textarea required cols="10" id="client-goals" name=
"client-goals" placeholder=
"What do you wish to acheive by having a website? ie. creating a web presence, expanding sales by creating an online market, networking, ect."
rows="5">
</textarea></p>
<h3 class="color-text">What key fatures are you looking
for?</h3>
<p class="contact-message">
<textarea required cols="10" id="client-needs" name=
"client-needs" placeholder=
"What key features are you looking to have within your website? ie. storefront, social media intigrtion, a blogging platform, content managment system, ect."
rows="5">
</textarea></p>
<script type = "text/javascript" >
var i = 1;
function addUrl() {
if (i < 3) {
i++;
var p = document.createElement('p');
p.innerHTML =
'<hr><textarea required id="client-needs" placeholder="Add URL #' + i +
'" name="example' + i +
'" rows="1" cols="10"><\/textarea><input type="button" value="Remove added URL" onclick="removeUrl(this)">';
document.getElementById('example').appendChild(p);
} //END if
} //END addUrl function
function removeUrl(textarea) {
textarea.parentNode.parentNode.removeChild(textarea.parentNode);
i--;
} //END removeUrl function
</script>
<h3 class="color-text">Do you have and examples of what
you want?</h3>
<p class="contact-message" id="example">
<textarea cols="10" id="examples" name="example1"
placeholder="Do you know of any website like the one you want? ie. google.com, p5services.com, youtube.com"
rows="1">
</textarea></p><br>
<input onclick="addUrl()" type="button" value=
"Add url example">
<h3 class="color-text">Do you have a budget in
mind?</h3>
<p class="contact-message">
<textarea required cols="10" id="client-budget" name=
"client-budget" placeholder=
"Enter a budget, approximate or exact. This will help us decide if the scope of your project is in line with what you are interested in spending"
rows="2">
</textarea></p>
<h3 class="color-text">Do you have a timeline or
deadline?</h3>
<p class="contact-message">
<!-- <textarea id="client-deadline" placeholder="When do you need this done by?" name="client-deadline" rows="2" cols="10"></textarea> -->
<!-- <input id="client-deadline" name="client-deadline"
type="date"></p> -->
<!-- add a call to action for further services later -->
<h3 class="color-text">Any other comments?</h3>
<p class="contact-message">
<textarea cols="10" id="client-comments" name=
"client-comments" placeholder=
"Don't let us over look anything!" rows="5">
</textarea></p>
<p class="contact-submit"><input name=
"submit_assessment" type="submit" value=
"Save New Record"></p>
<div id="response"></div>
</form>
</div>
<div class="span3">
<div class="contact-details">
<h3><span class="font-icon-info"></span> Assesment
Objective</h3>
<p>The assesment section is used to define your needs
and help us decided what tool we need to impliment in
order to help you reach your goals</p>
<h4 class="color-text">After submitting this you will
recive a quote!</h4>
</div>
</div>
</div><!-- End main Form -->
</div>
</div><!-- End main Section -->
<?php
include '_include/php/footer.php'; ?>
The textarea element takes placeholder text in a different form. You need to put it between the tags like so:
<textarea>My text area placeholder text goes here</textarea>
The space that you are seeing then deleting to see your placeholder is caused by the line break between your opening and closing textarea tags
Related
I have created a form for something i call a site survey. Before i had the form one one page. But decided to spread it across three html/css tabs. At first it did let me submit to a MySQL db. But I didn't make a backup of a working example with the tabs as it wasn't fully what I wanted yet.
Now it glitches and wont create a new record in the db
Problem
I fill in the first part of the form which works Okay. I click next to send me to the next tab. and go to fill in the rest of the form. I am instantly seeing one of the "please fill out this field" because it is "required" in the code. Once filled, i press the next button again. Which this then takes me to the next tab but then instantly to the first tab and refreshes everything
The next and previous buttons work and dont glitch when there are no answers entered into the fields
I have no idea how to solve the problem. Which is why I'm seeing if anyone can help.
edit
I changed the button to an A tag like the "previous" a tag does. This stops the glitches. However the form does not submit...
Function for the Next/Previous button to work -
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
$('.next-button').click(function(){
$('.nav-tabs > .active').next('li').find('a').trigger('click');
//trigger the click on the tab same like we click on the tab
});
$('.previous-button').click(function(){
$('.nav-tabs > .active').prev('li').find('a').trigger('click');
//trigger the click on the tab same like we click on the tab
})
</script>
HTML Code -
<div class="row"> <!-- 2 -->
<form class="row g-3" action="<?= $data['action'] ?>" method="post"><!-- 3 -->
<div class="col-sm-12 survey-tabs"> <!-- 4 -->
<ul class="nav nav-tabs" hidden>
<li class="active">Contact & Site Details</li>
<li class="">Questions</li>
<li class="">Site Details</li>
</ul>
<div class="tab-content"><!-- 5 -->
<div class="tab-pane active" id="tab1">
<h1>Contact & Site Details</h1>
<div class="row"> <!-- START TAB ROW 1 -->
<div class="col-md-7">
<label for="site_name" class="form-label">Site Name*</label>
<input type="text"
class="form-control"
id="site_name"
name="site_name"
value="<?= $data['record']['site_name'] ?? '' ?>"
placeholder="Enter Site Name"
required><br>
</div>
<div class="col-md-5">
<label for="poNum" class="form-label">PO Number*</label>
<input type="text"
class="form-control"
id="poNum"
name="poNum"
value="<?= $data['record']['poNum'] ?? '' ?>"
placeholder="Enter PO Num (Given in Email)"
required>
</div>
<div class="tab-control">
<a class="next-button" role="button"><button class="btn btn-primary">Next</button></i></a>
</div>
</div>
<!---------------------------------------------------------------------------------------------------------------------------------------->
<div class="tab-pane" id="tab2">
<h1>Questions</h1>
<div class="row"><!-- START TAB ROW 2 -->
<div class="col-12">
<h6 for="current_machine">1. What is your Current Machine?</h6>
<input type="text"
class="form-control"
id="current_machine"
name="current_machine"
value="<?= $data['record']['current_machine'] ?? '' ?>"
placeholder="Leave blank if none"><br>
</div>
<div class="col-12">
<h6 for="ordered_machine">2. What Machine did you Order?*</h6>
<input type="text"
class="form-control"
id="ordered_machine"
name="ordered_machine"
value="<?= $data['record']['ordered_machine'] ?? '' ?>"
placeholder="Machine(s) Ordered"
required> <br>
</div>
</div> <!-- END TAB ROW 2 -->
<div class="tab-control">
<a class="previous-button" role="button"><i class="fa fa-angle-left fa-3x fa-fw"></i></a>
<a class="next-button" role="button"><button class="btn btn-primary">Next</button></i></a>
</div>
</div>
<!---------------------------------------------------------------------------------------------------------------------------------------->
<div class="tab-pane" id="tab3">
<h1>Site Details</h1>
<div class="row"><!-- START TAB ROW 3 -->
<div class="col-12">
<h6 for="q7">9. What floor is the Machine(s) going to be located on?</h6>
<input type="text"
class="form-control"
id="q7"
name="q7"
value="<?= $data['record']['q7'] ?? '' ?>"
placeholder="Please enter what floor your machine will be located on"> <br><br>
</div>
</div> <!-- END TAB ROW 3 -->
<div class="tab-control">
<a class="previous-button" role="button"><i class="fa fa-angle-left fa-3x fa-fw"></i></a>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary mb-3"><?= $data['button'] ?></button>
</div>
</div>
</div><!-- 5 -->
</div><!-- 4 -->
</form><!-- 3 -->
</div> <!-- 2 -->
</div><!-- 1 -->
I want to handle row in bootstrap. Kindly check what i am doing:
<div class="form-group col-md-6">
<?php if($saved_image != ''): ?>
<div style="width:100px; height:100px">
<img class="img-thumb" src="<?=$saved_image;?>" alt="saved image" />
<br>
Delete Image
<!-- Start Another image 2 -->
<img class="img-thumb" src="<?=$saved_image;?>" alt="saved image" />
<br>
Delete Image
<!-- End Another image 2 -->
</div>
<!-- If Edit Happen - End -->
<?php else:?>
<!-- If image empty or user first time add product[data is not saved in the database] -->
<label for="photo">Product Photo:</label>
<input class="form-control" type="file" name="photo[]" id="photo" multiple>
<?php endif;?>
</div> <!-- close form-group div -->
<div class="form-group col-md-6">
<label for="description">Description:</label>
<textarea class="form-control" name="description" id="description" rows="6"><?= $description ;?></textarea>
</div>
Kindly check the below image what I am getting the output:
I want iron images will show next to each other and if more images are there then it will show on the next line but not below the description box. The description box will be there always where it is showing right now.
Kindly suggest what I am doing wrong. Your suggestions would be welcome.
you can try with more div tags in your existing code..
<div class="form-group col-md-6">
<?php if($saved_image != ''): ?>
<div class="col-md-6"><!-- This is EDITED-->
<img class="img-thumb" src="<?=$saved_image;?>" alt="saved image" />
<br>
Delete Image
</div> <!-- This Is ADDED NEWLY-->
<div class="col-md-6"> <!-- This Is ADDED NEWLY-->
<!-- Start Another image 2 -->
<img class="img-thumb" src="<?=$saved_image;?>" alt="saved image" />
<br>
Delete Image
<!-- End Another image 2 -->
</div> <!-- This Is ADDED NEWLY-->
</div>
<!-- If Edit Happen - End -->
<?php else:?>
<!-- If image empty or user first time add product[data is not saved in the database] -->
<label for="photo">Product Photo:</label>
<input class="form-control" type="file" name="photo[]" id="photo" multiple>
<?php endif;?>
I am quite a rookie when it comes to website design, but I managed to set up a website with bootstrap and jquery including a small form (inside a modal) for guests to register to an event.
The form sends its data (attending, name, etc) to a php script which then sends it to mail and echos the mailbody which is then also displayed in an iFrame for the user to see the confirmation.
Everything works fine on PC. I have tested it on three different machines with chrome, firefox and IE.
It works equally well on my personal Android phone.
Here is the catch: On my company Blackberry and on my sister's Android it does not work. The form seems to work and triggers the PHP but it seems to pass only empty variables. The generated mail and the confirmation in the iFrame is blank.
Any ideas what is wrong? Security settings or anything that prevents actual data to be send? I am puzzled and googled this for an hour without finding a solution...
The code (shortened):
<form action="rueckmeldung.php" method="post" autocomplete="off" target="hiddenForm" onsubmit="this.reset();" content="text/html; charset=UTF-8" > <!-- onsubmit="this.submit(); this.reset(); return false; window.location.assign('#close')"-->
<IFRAME style="display:none; width:100%; height:auto; border:0; margin-left: 5rem; margin-right: 5rem;" name="hiddenForm" id="hiddenframeID" class="mdlRMhide2"></IFRAME>
<!-- Modal Body -->
<div class="modal-body mdlRMhide1" novalidate="novalidate">
<!-- Ja/Nein-->
<section id="secJaNein" class="modal-section">
<div class = "row">
<div class="col-xs-12 col-sm-6">
<div class="input-wrap"><input type="radio" name="entrykommejanein" id="e1" value="Ja" required />
<label for="e1"><h3>Natürlich komme ich!</h3></label></div>
</div>
<div class="col-xs-12 col-sm-6">
<div class="input-wrap"><input type="radio" name="entrykommejanein" id="e2" value="Nein" required />
<label for="e2"><h3>Leider schaffe ich es nicht</h3></label></div>
</div>
</div>
</section>
<!-- Name Gast -->
<section id="secGast" class="modal-section">
<div class= "row">
<div class="col-xs-12 col-sm-6 ">
<div class="form-group has-feedback">
<label for="gastVorname"><h2>Vorname</h2></label>
<input type="text" name="entryvorname" id="gastVorname" class="form-control" required >
<!-- <small class="help-block" data-fv-validator="notEmpty" data-fv-for="guest-first-name" data-fv-result="NOT_VALIDATED" style="display: none;">First name is required</small> -->
</div>
</div>
<div class="col-xs-12 col-sm-6">
<div class="form-group has-feedback">
<label for="gastNachname"><h2>Nachname</h2></label>
<input type="text" name="entrynachname" id="gastNachname" class="form-control" required >
</div>
</div>
</div>
</section>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<div class = "row">
<div class="col-xs-6 mdlRMhide1">
<button class="button btn btn-lg form-btn" type="submit" value="Submit" >Abschicken</button>
</div>
<div class="col-xs-12 mdlRMhide2" style="display:none">
<button class="button btn btn-lg form-btn btnModalRMClose" data-dismiss="modal">Schließen</button>
</div>
</div>
</div>
</form>
PHP:
<?php
$myemail = 'mail#domain.com';
$kommejanein = $_POST['entrykommejanein'];
$vorname = $_POST['entryvorname'];
$nachname = $_POST['entrynachname'];
$to = $myemail;
$email_subject = "Rückmeldung von $vorname $nachname : $kommejanein";
$email_body = "\n Teilnahme: $kommejanein \n Gast: $vorname $nachname";
$headers = array();
$headers[] = "From: $myemail";
$headers[] = "Reply-To: $myemail";
$headers[] = "Content-type: text/plain; charset=utf-8";
mail($to,$email_subject,$email_body,implode("\r\n",$headers));
echo nl2br($email_body);
?>
Could it be that the opening form-tag is missing? Use var_dump($_POST) to check results on targeted page.
So, I finally found the problem, although I do not quite understand, why it caused trouble on one android but not on another and not on PC...
After taking out
onsubmit="this.reset();"
it worked on all devices (so far) and the formular content is forwarded to PHP.
I am using the geocoding control plugin L.GeoSearch (https://github.com/smeijer/L.GeoSearch) and I have a form on the left sidebar of my leaflet map. The form should submit the inputs to a php file that then does the processing via XMLHttpRequest.
The coordinates have to be transferred as well and I am a little bit stuck on how to integrate the geosearch bit into the form. Can somebody help me out or give some hints?
The page: http://app.seedbomb.city/cartodb.html
This is my map code:
https://jsfiddle.net/Gopher69/oza08ja4/embedded/result/
<!-- Begin Sidebar!-->
<div id="sidebar">
<h2>Markiere deinen Standort</h2>
<div class="ss-form-container">
<div class="ss-header-image-container">
<div class="ss-header-image-image">
<div class="ss-header-image-sizer"></div>
</div>
</div>
<div class="ss-top-of-page"></div>
<div class="ss-form">
<form onsubmit="" target="_self" id="ss-form" method="POST" action="write_cartodb.php">
<ol style="padding-left: 0" class="ss-question-list" role="list">
<div role="listitem" class="ss-form-question errorbox-good">
<div class="ss-item ss-text" dir="auto">
<div class="ss-form-entry">
<label for="entry_2039516724" class="ss-q-item-label">
<div class="ss-q-title">Bildbeschreibung
</div>
<div dir="auto" class="ss-q-help ss-secondary-text"></div>
</label>
<input type="text" title="" aria-label="caption " dir="auto" id="entry_2039516724" class="ss-q-short" value="" name="beschreibung">
</div>
</div>
</div>
<div role="listitem" class="ss-form-question errorbox-good">
</br>
<input type="file" name="bild" id="uploadfiles" accept="image/*" />
</div>
</div>
</div>
</br>
</br>
<div class="ss-item ss-navigate">
<table id="navigation-table">
<tbody>
<tr>
<td dir="ltr" id="navigation-buttons" class="ss-form-entry goog-inline-block">
<input type="submit" class="jfk-button jfk-button-action " id="ss-submit" value="Senden" name="submit">
</tr>
</tbody>
</table>
</div>
</div>
<!-- End Sidebar!-->
The php processing file:
https://jsfiddle.net/Gopher69/c692kqov/embedded/result/
<?php
echo "<h1>" . $_POST["beschreibung"] . "</h1>";
echo "<h1>" . $_POST["bild"] . "</h1>";
?>
<script>
function dialResponse() {
console.log(this.responseText); //should be return value of 1
}
var oReq = new XMLHttpRequest();
oReq.onload = dialResponse;
oReq.open("get", "https://{account}.cartodb.com/api/v2/sql?q=INSERT INTO cartodb_test (caption, image_low, image_standard, image_thumb, latitude, longitude) VALUES (<?php echo $beschreibung;?>, http://app.seedbomb.city/images/<?php echo $bild;?>, http://app.seedbomb.city/images/<?php echo $bild;?>, http://app.seedbomb.city/images/<?php echo $bild;?>, 12.532534, 12.643245)&api_key=http://app.seedbomb.city/images/<?php echo $bild;?>"
", true);
oReq.send();
</script>
You can utilize Leaflet's map events, such as click or moveend, to let a user chose the position.
With those you can fill an input field in your form with the coordinates. This code will update an input field with a coordinate when clicking on the map:
map.on('click', function(e){
document.getElementById('userlocation').value = e.latlng.lat+','+e.latlng.lng;
});
Demo code here: https://jsfiddle.net/chk1/dh58ury9/
I have a HTML Form that uses partial PHP to grab the value, the form is basically like an edit account details form.
The Problem
I cannot work out why the form is not working and when using notepad++ to edit my code if I click on the it shows the start to be a DIV which just confuses the matter even more... When submitting the form it takes you back to the form page with no message so I am lost for a reason..
Form Page
<form method="POST" action="dev.php">
<!-- Row -->
<div class="row-fluid">
<!-- Column -->
<div class="span6">
<!-- Group -->
<div class="control-group">
<label class="control-label" for="fname">First name</label>
<div class="controls">
<input type="text" name="fname" id="fname" value="<?php echo $user_fname; ?>" class="span10" />
<span style="margin: 0;" class="btn-action single glyphicons circle_question_mark" data-toggle="tooltip" data-placement="top" data-original-title="First name is mandatory"><i></i></span>
</div>
</div>
<!-- // Group END -->
<!-- Group -->
<div class="control-group">
<label class="control-label" for="lname">Last name</label>
<div class="controls">
<input type="text" name="lname" id="lname" value="<?php echo $user_sname; ?>" class="span10" />
<span style="margin: 0;" class="btn-action single glyphicons circle_question_mark" data-toggle="tooltip" data-placement="top" data-original-title="Last name is mandatory"><i></i></span>
</div>
</div>
<!-- // Group END -->
</div>
<!-- // Column END -->
<!-- Column -->
<div class="span6">
<!-- Group -->
<div class="control-group">
<label class="control-label" for="email">Email Address</label>
<div class="controls">
<input type="text" name="email" id="email" value="<?php echo $user_email; ?>" class="span10" />
<span style="margin: 0;" class="btn-action single glyphicons circle_question_mark" data-toggle="tooltip" data-placement="top" data-original-title="First name is mandatory"><i></i></span>
</div>
</div>
<!-- // Group END -->
<!-- Group -->
<div class="control-group">
<label class="control-label" for="phonenumber" >Phone Number:</label>
<div class="controls">
<input type="text" name="phonenumber" id="phonenumber" value="<?php echo $user_number; ?>" class="span10" />
</div>
</div>
<!-- // Group END -->
</div>
<!-- // Column END -->
</div>
<!-- // Row END -->
<div class="separator line bottom"></div>
<!-- Group -->
<div class="control-group row-fluid">
<label class="control-label" for="bio">About me</label>
<div class="controls">
<textarea id="bio" name="bio" class="span12" rows="5"><?php echo $user_bio;?></textarea>
</div>
</div>
<!-- Form actions -->
<div class="form-actions" style="margin: 0;">
<button type="submit" id="accountdetails" name="accountdetails" class="btn btn-icon btn-primary glyphicons circle_ok"><i></i>Save changes</button>
</div>
</div>
</form>
<!-- // Form actions END -->
dev.php
if (isset($_POST['accountdetails'])) {
if (isset($_POST['fname']) || isset($_POST['lname']) || isset($_POST['email']) || isset($_POST['phonenumber']) || isset($_POST['bio'])) {
die ("HERE");
};
};
I probably need to drink more Coffee but I cannot for the life of me work out why it is not working.
Any help would be appreciated!
Thanks in advance.
EDIT
I put the name's in and this did not help, now the URL of the page shows this:
update.php?fname=Aaron&lname=Hatton&email=me%40aaronhatton.co.uk&phonenumber=0123456789&bio=+18+%7C+London+%7C+Taken&accountdetails=
any ideas?
One: do what Fred said (name attributes on your input tags).
Two: You're missing the </form> tag at the end.
Your form page seems correct, however, since the form updates the user data, look what the dev.php code is doing:
isset() function returns true if the value is set and you manual set the fields so it will evaluate to true.
and in your if statement you are ORing all the conditions so as soon as it finds 1 true condition, it will go into the if statement body and execute die which will do nothing.
so if you want to test, instead of using die, try echo "here" to see if a message is printed.
So I found out the form works perfect and there was some AJAX being used by another coder, removed and surprise surprise it works perfectly!
Damn co-workers!
Thanks to all that helped!