Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Using this video: https://www.youtube.com/watch?v=ueruxlD0Smo&index=6&list=PLE134D877783367C7
I have tried to make a login system, the problem is, he has his login on his main page. So he made it when you click login it re-directs to login.php, but I have a login page, so I dont know how to make it check the database, then login and send to the main page. here is my code..
<?php
$pagetTitle = "Corvex | Logon";
$pageID = 2;
include 'include/header.php';
include 'core/init.php';
if(empty($_POST) === false){
$username = $_POST['username'];
$password = $_POST['password'];
echo $username, ' ', $password;
}
?>
<style>
.form-signin {
max-width: 330px;
padding: 15px;
margin: 0 auto;
}
</style>
<form>
<h1>Employer Log in</h1>
<div class="inset">
<p>
Username
<input type="text" name="username">
</p>
<p>
Password
<input type="password" name="password">
</p>
<p>
<input type="checkbox" name="remember" id="remember">
<label for="remember">Remember Me</label>
</p>
</div>
<p class="p-container">
<span> Forgot Password </span>
<input type="submit" name="go" id="go" value="Log in">
</p>
</form>
<?php include 'include/footer.php'; ?>
Basically when the HTML form gets posted you need to check the $_POST for the dictionary of values necessary to input in the database. The 'name' attribute in HTMl is what the key will be in the $_POST dictionary.
You need to change <form> to <form action="login.php" method="POST"> so that the data is sent to the right page. Them at the top you are already checking the values to see if they are set.
You should reference http://php.net/manual/en/function.mysql-query.php to look at functions necessary to communicate with MySQL to submit this data.
Related
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 6 years ago.
Improve this question
Sorry for my spelling
Hi, im trying to make a website showing internet forfeit, so in mySQL database i put all my information then I print it on my web page, the the user click on the forfeit he wants, it brings him to an other page that shows all the forfeit informations... In the while(), I'm making unique form for each forfeit, then on the
The problem here is that the only form sumbitted is the last one created
include_once "DataBase/db.php";
if($internet->num_rows != 0){
while($rows = $internet->fetch_assoc()){
$nom = $rows["nom"];
$id = $rows["id"];
$tech = $rows["technologie"];
$telechargement = $rows["telechargement"];
$televersement = $rows["televersement"];
$utilisation = $rows["utilisation"];
$prix= $rows["prix"];
echo '
<form method="POST" action="Fournisseurs/Videotron.php" id="'.$id.'">
<div class="boxes">
<div class="[ price-option price-option--high ]">
<div class="price-option__detail">
<span class="price-option__cost">'.$nom.'<br>$'.$prix.'</span>
</div>
<input type="hidden" name="id" value="'.$id.'"></input>
<input type="hidden" name="nom" value="'.$nom.'"></input>
<input type="hidden" name="tech" value="'.$tech.'"></input>
<input type="hidden" name="telechargement" value="'.$telechargement.'"></input>
<input type="hidden" name="televersement" value="'.$televersement.'"></input>
<input type="hidden" name="utilisation" value="'.$utilisation.'"></input>
<input type="hidden" name="prix" value="'.$prix.'"></input>
<div class="price-option__purchase">
Submit
</div>
</div>
</div>
';
}
}
You can see what i'm talking about here : http://fournisseursquebec.com/Forfaits.php
just select internet
Thank you!
You are missing the closing </form> tag for every box. Now you have one big form with a lot of repeated fields:
<form method="POST" action="Fournisseurs/Videotron.php" id="'.$id.'">
box 1:
<input type="hidden" name="id" value="'.$id.'"></input>
.... box 2:
<input type="hidden" name="id" value="'.$id.'"></input>
...
The name attribute of the various input is the one that is sent and should be unique inside every form.
Just add the </form> tag in your while loop and it should work.
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 7 years ago.
Improve this question
I have this code for send date:
<form enctype="multipart/form-data" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<input name="file[]" type="file" id="img">
<textarea name="file[]" rows="5" cols="50" id="textarea"></textarea>
<input name="file[]" type="text" id="text" value="">
<input type="submit" value="upload" name="submit" id="upload" class="upload"/>
</form>
and this code:
<?php
if (isset($_POST['submit'])){
$textarea=$_POST['file'];
$implodetextarea=implode(",",$textarea);
for ($i = 0; $i < count($textarea); i++){
echo $textarea['id'][$i];//This is wrong
}
}
?>
Now how to get the type of data and how you can distinguish between the image or text, or others?
Data validation in Windows is based on the honor system - a file's suffix (.txt, .jpg, .zip, etc.) tells the system what kind of data is in the file. Of course a suffix can be changed, so it's not a perfect system. In other operating systems file suffixes are less prevalent and data validation, when required, must be done by examining the contents of the file. For example, if you're expecting the user to upload a jpg, you can use PHP's fopen and fread to search the uploaded file for jpg headers. In short, you can't be sure what kind of file is being uploaded without cracking it open and reading the contents.
You can look for the files mime type.
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 want to submit the form after an if statement for example:
<?Php
if($something){
?>
<script type="text/javascript">
document.getElementById('dateForm').submit(); // SUBMIT FORM
</script>
<form id="dateForm" action="https://www.paypal.com/cgi-bin/webscr" method="POST">
<input type="hidden" name="test" value="test">
<input type="hidden" name"test2" value="Support">
</form>
<?php
}
?>
However, this doesn't work.
Put the script after the form tag. It searches dateForm id and until that no form is in the output so it does nothing. When you place that after it, it'll search the page for that id and it finds that and submits.
<?Php
if($something):?>
<form id="dateForm" action="https://www.paypal.com/cgi-bin/webscr" method="POST">
<input type="hidden" name="test" value="test">
<input type="hidden" name"test2" value="Support">
</form>
<script type="text/javascript">
document.getElementById('dateForm').submit(); // SUBMIT FORM
</script>
<?php
endif;?>
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 want to add values to my MySql database using PHP. The values I want to add, will come from the text-boxes of a form. I tried $variable = $_POST['formElementName'] and used $variable to insert values. But it doesn't work.
Question:
How can I put the values of the text-boxes into variables?
Thanks.
Use below code for the form
<form name="form-name" action="" method="POST">
<input type="text" name="fieldname1" value="" />
<input type="text" name="fieldname2" value="" />
</form>
and for php manipulation at server end, you will get values in $_POST i.e.
$_POST['fieldname1'] and $_POST['fieldname2]
I just want to elaborate what #Kyle wrote
Note: The form method is POST
HTML part
<form action="your_php_file_name.php" method="POST">
<input type="text" name="first_name" />
<input type="submit" value="Submit" />
</form>
PHP part: The file name is: your_php_file_name.php
<?php
//A good practice to check the type of HTTP request
$fname = $_POST['first_name'];
?>
Some good practices
Check the HTTP request type sent from the client side. (I find it a good way)
Sanitize the variables before inserting.
Here's an idea:
Client-side:
<input type="text" name="first_name">
Server-side:
$var = $_POST["first_name"];
Just to add to Kyle's answer above, Make sure you have value="Something" set, otherwise it will return nothing.
<input type="text" name="first_name" value="Testing">
Server Side
$var = $_POST["first_name"];
For debugging I use:
print_r($_POST)
This will return all the POST values set and is really handy.
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 don't know Ajax or PHP but I want to submit this form without page refresh and also want to appear check icon beside the submit button. How can I do this?
<form id="form" action="" method="post">
<input type="text" id="email" value="e-mail address" />
<input type="submit" id="submit" name="submit" value="Submit" />
</form>
<script>
function xyz(){
var email_val=$('#email').val();
$.post("ajax.php",{"email":email_val},function(data){
if(data) {
$('#message').html('Data submit successfully');
$('#email').val('');
}
else{
$('#message').html('Failed');
}
});
}
</script>
<form id="form" action="" method="post" onsubmit="xyz()">
<input type="text" id="email" value="e-mail address" />
<input type="submit" id="submit" name="submit" value="Submit" />
<span id="message"></span>
</form>
ajax.php
if(isset($_REQUEST['email'])){
//Your code here
}
If you are not aware of AJAX and PHP but still you have to submit a form without page reload then follow this tutorial.. do some home works
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/