When uploading file, it show error message (PHP) [closed] - php

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 9 months ago.
Improve this question
I try to upload a Image by using PHP. I need to save image in my database. this is my HTML file. I dont know how to pass data file
<form action="insert.php" method="post">
<p>
<label for="firstName">First Name:</label>
<input type="text" name="first_name" id="firstName">
</p>
<p>
<label for="lastName">Last Name:</label>
<input type="text" name="last_name" id="lastName">
</p>
<p>
<label for="Gender">Gender:</label>
<input type="text" name="gender" id="Gender">
</p>
<p>
<label for="Address">Address:</label>
<input type="text" name="address" id="Address">
</p>
<p>
<label for="emailAddress">Email Address:</label>
<input type="text" name="email" id="emailAddress">
</p>
<input type="submit" value="Submit">
</form>

Use enctype='multipart/form-data'
<form action="insert.php" method="post" enctype='multipart/form-data'>

Related

HTML form not sending POST data (or PHP not receiving it)

Yes, forms of this question are asked all the time. Due to the infinite possible ways that one can construct a form/php pair, my question still is different. (and much simpler)
I have:
<html>
<body>
<form id="request-inspecton" action="test_form_processor.php" method="POST">
<label class="text-label" for="FirstName">*first name:</label>
<input class="text-input" type="text" name="FirstName" id="FirstName" required="required" placeholder="First Name">
<label class="text-label" for="LastName">*last name:</label>
<input class="text-input" type="text" name="LastName" id="LastName" required="required" placeholder="Last Name">
<input class="button-input" type="submit" value="send" id="buttonSend" name="submitForm" placeholder="Submit form" value="POST">
</form>
</body>
</html>
and:
<?php
var_dump($_POST);
print $_POST["FirstName"];
?>
But all I get is:
array(0) { }
Golly, I just can't figure out what is wrong!\
Incidentally, example currently at:
http://checkitouthomeinspection.com/test_form.html
Strangely enough, it now works in both FF and Chrome. Beats me what the problem was. Thanks for the help. Case closed.

Pre checked check box [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a site that has multiple ways to access our "email me for more information" form.
On the form, it has a list of checkboxes that they can check that they want to be emailed about more information for. Is it possible to have the check box prechecked depending on what page they come from?
For example, they visit our "Product 12" page and follow the link to the form and there is a checkbox to receive more information on Product 12 that is pre-checked because they came to the form from the Product 12 page.
Here is my form code:
<form id="formElem" name="formElem" action="" method="post">
<fieldset class="step">
<legend>Personal Details</legend>
<p>
<label for="fullname">Full Name</label>
<input id="fullname" name="username" />
</p>
<p>
<label for="company">Company Name</label>
<input id="company" name="company" />
</p>
<p>
<label for="title">Title</label>
<input id="title" name="title" />
</p>
<p>
<label for="phone">Phone Number</label>
<input id="phone" name="phone" />
</p>
<p>
<label for="email">Email</label>
<input id="email" name="email" placeholder="info#.com" type="email" AUTOCOMPLETE=OFF />
</p>
</fieldset>
<fieldset class="step">
<legend>Products I'm interested in...</legend>
<p>
<input type="checkbox" name="telematics" value="telematics">Telematics<br>
</p>
<p>
<input type="checkbox" name="controllers" value="controllers">Controllers<br>
</p>
<p>
<input type="checkbox" name="cots" value="cots">Custom-off-the-Shelf<br>
</p>
<p>
<input type="checkbox" name="displays" value="displays">Displays\Operator Interfaces<br>
</p>
<p>
<input type="checkbox" name="cordReels" value="cordreels">Cord Reels<br>
</p>
<p>
<input type="checkbox" name="pdm" value="pdm">Power Distribution Modules<br>
</p>
<p>
<input type="checkbox" name="rtc" value="rtc">Real Time Clock<br>
</p>
</fieldset>
<fieldset class="step">
<legend>Services I'm interested in...</legend>
<p>
<input type="checkbox" name="productDev" value="productdev">Product Development<br>
</p>
<p>
<input type="checkbox" name="desEng" value="deseng">Design Engineering<br>
</p>
<p>
<input type="checkbox" name="dfx" value="dfx">DFX<br>
</p>
<p>
<input type="checkbox" name="transServices" value="transServices">Transition Services<br>
</p>
<p>
<input type="checkbox" name="stratSourcing" value="stratSourcing">Strategic Sourcing<br>
</p>
<p>
<input type="checkbox" name="planning" value="planning">Planning<br>
</p>
<p>
<input type="checkbox" name="manufacturing" value="manufacturing">Manufacturing<br>
</p>
<p>
<input type="checkbox" name="fullfillment" value="fullfillment">Fullfillment<br>
</p>
<p>
<input type="checkbox" name="prodLifecycle" value="prodLifecycle">Product Life-Cycle Management<br>
</p>
</fieldset>
<fieldset class="step">
<legend>Confirm</legend>
<p>Everything in the form was correctly filled
if all the steps have a green checkmark icon.
A red checkmark icon indicates that some field
is missing or filled out with invalid data.
</p>
<p class="submit">
<button id="registerButton" type="submit">Register</button>
</p>
</fieldset>
</form>
The serverside code will be PHP.
Plz respond.
If I was in your shoes, I would use a query string variable to pass the ID of your page (or product ID would be ideal) on the link linking your product page to the form.
ie.) /formPage.html?id=12
On the form page, give each input element a unique ID. Then using either server side code or javascript, check if the id is present in the querystring, if so, check what it is and programatically check your checkbox.
It's easy with jquery:
$("#product12ID").prop("checked", true); <---- This will check the checkbox that has an id=product12ID
It would be helpful to know what language you're using (ASP.NET, PHP, etc). It would help fine tune what direction to go in.

Receive form data on email

How may I get data of this form to be received in an email?
<form class="pa">
<fieldset>
<label>Name <em>*</em></label>
<input type="text" placeholder="">
<label>Email <em>*</em></label>
<input type="text" placeholder="">
<label>Age <em>*</em></label>
<input type="text" placeholder="">
<label>Phone <em>*</em></label>
<input type="text" placeholder="">
<label>Zip Code <em>*</em></label>
<input type="text" placeholder="">
<a class="submit pa" href="#"><img src="wp-content/themes/child/img/submit.png"</a>
</fieldset>
</form>
You'll need a server-side script to accept the form data, and send an email with it. You can do this PHP and several other languages. Judging by your sample code you have WordPress, so you might look into the ContactForm plugin.
wrap your input's with something like
<form class="pa" action="yourscript.php" method="post">
.
.
<label for="name">Name <em>*</em></label>
<input type="text" placeholder="" id="name" name="name">
.
<input type="submit" value="Submit" />
<!-- remove the a tag because that won't submit your form data or use type="image" -->
<input type="image" src="wp-content/themes/child/img/submit.png" />
</form>
then use $_POST['name'] to retrieve the value
you have to add name='' to each inputs to have them sent to your script eg <input type="text" id="name" name="name"> and they have to be different otherwise they might get overridden.
also your labels will need the for= to be useable which uses the id of the input eg <label for="name">Name <em>*</em></label>

New input not posted [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've got a form with 6 inputs of different types (select, radio, text...). When I debug with Xdebugg I can see the values in $_POST variable,
I've decided to add other input but they arent posted : when I look at $_POST variable, I just have the first 6 values.
Here's a part of my form :
edit : i've copy/paste the code this time. My boss told me to not send the real code, that's why I've send a fake code but i really need some help so here's the real one.
<div id="modifierUser" class="divAdmin">
<form id="modifierUserForm" name="modifier_user"action="includes/inc_adminModifierUser.php">
<fieldset>
<legend>
<img src="img/bulle_48.png" alt="bulle" title="bulle" />
<h3>Modifier le compte</h3><br />
</legend>
<!-- the field i've tried to add -->
<label class ="labelEmail" for="idmembre">ID du membre </label>
<input id="idmembre" name="idmembre" size="35" class="required"/>
<!-- -->
<label class ="labelEmail" for="pseudo">Utilisateur </label>
<input id="pseudo" name="pseudo" size="35" class="required"/>
<label class ="labelEmail" for="anneeNaiss">Année de naissance </label>
<input id="anneeNaiss" name="anneeNaiss" placeholder="e.g : 1984" size="35" class="required" maxlength="4" value="" />
<label class ="labelEmail" for="email">Email </label>
<input id="mail" type="email" name="email" size="35" class="email" value="" maxlength="50"/>
<label class ="labelEmail" for="telephone">Téléphone</label>
<input id="telephone" type="tel" name="telephone" size="35" class="required" value="" maxlength="10" />
<label class ="labelEmail"> Masquer numéro dans l'annonce</label>
<input type="radio" name="masquerTel" value="oui" id="oui" checked="checked" />
<span>Oui</span>
<input type="radio" name="masquerTel" value="non" id="non" /><span>Non</span>
<label class ="labelEmail" for="region">Région</label>
<select id="region" name="region" size="1" class="required" style="width:180px"
<option value="Aquitaine" selected="selected" >Aquitaine </option>
<option value="Alsace">Alsace </option>
<!-- There's many options there-->
</select>
<input type="submit" name="enregistrer" value="Enregistrer les modifications" size="35"/>
<input type="button" name="annuler" class="annuler" value="ANNULER" />
</fieldset>
</form>
</div><!--fin modifierUser-->
variable i can see :
$_POST['pseudo']
$_POST['anneNaiss']
$_POST['email']
$_POST['telephone']
$_POST['masquerTel']
$_POST['region']
i'll always have $_POST[6]in xdebug, no matter how many input i add. But i tried to suppress one of 6 above input and i got $_POST[5].
The one I need to see
$_POST['idmembre']
Sorry for wasting your time
It looks as if the values aren't being posted because you've mispelt "action", calling it "ation" in the form element starting tag. <form>.
Because of this your form will be posting to the same page it's output in, rather than the page you're trying to POST the data to.
The first line of your code should look like this instead:
<form id="modifyUserForm" name="modify_user" action="includes/inc_adminModifyUser.php">
it seems that you have an extra double quote in your code so thats normal you HTML code does not render correctly:
<input id="inp_realname" name="realname" size="35" "/>
should be:
<input id="inp_realname" name="realname" size="35" />

Passing php form info to javascript form

I hope someone can help me. I'm a little at loss on how I can achive this: I'm trying to pass infos generated in my php to another form made in Javascript. For example, if I put my first name in the input field and click submit, then it would go to another page with the actual form and have the first name already filled there.
One thing that I did notice was that the javascript form isn't within the <form> tag, it's in a bunch of tables with some input fields. I can post what it looks like in pastebin if this can help in understanding what I mean.
Also with this script im unable to edit it, I did not make it, it is one of those script you just place on your site thats auto generated.
My form looks like this:
<form action="auto-form/index.php" method="post" name="openleads" onsubmit="return checkForm(this);">
<label for="first">First Name <span class="required">*</span></label>
<input id="first_name" type="text" name="first" applicationforms="true" /><br>
<label class="error" for="name" id="first_name_error" style="color:#F00; font-size:11px;">This field is required.</label>
<span class="fields">Zip <span class="required">*</span></span>
<input id="zip" type="text" name="zip" applicationforms="true" /><br>
<label class="error" for="name" id="zip_error" style="color:#F00; font-size:11px;">This field is required.</label>
<label for="last">Last Name <span class="required">*</span></label>
<input id="last_name" type="text" name="last" applicationforms="true" /><br>
<label class="error" for="name" id="last_name_error" style="color:#F00; font-size:11px;">This field is required.</label>
<span class="fields">Email <span class="required">*</span></span>
<input id="email" type="text" name="email" applicationforms="true" /><br>
<label class="error" for="name" id="email_error" style="color:#F00; font-size:11px;">This field is required.</label>
<input class="button" type="submit" name="send" value="Send" />
</form>
Any help is appreciated; like I said, I'm a bit at loss on what to do with this one.
php-form.php
<form action="javascript-form.php" method="post">
<input type="text" name="name" />
<input type="submit" value="Submit" />
</form>
javascript-form.php
<form action="" method="">
<input type="text" name="name" value="<?= (isset($_POST['name'])?htmlentities($_POST['name'],ENT_QUOTES):''); ?>" />
<input type="submit" value="Submit" />
</form>
Use PHP to output the POSTed values in to the value attribute of the form fields. You can also use GET variables and use javascript to parse the window.location and scrape those form values.
this seemed to get this done
<script type="text/javascript" src="http://jquery.offput.ca/js/jquery.timers.js"></script>
<script>
$(document).everyTime(1000,function(i){
if($('#ui-datepicker-div').length>0)
{
$('#first_name').val('<?php echo $_POST['first_name']; ?>');
$('#last_name').val('<?php echo $_POST['last']; ?>');
$('#zip').val('<?php echo $_POST['zip']; ?>');
$('#email').val('<?php echo $_POST['email']; ?>');
}
})
$('#first_name').val('test');
</script>

Categories