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.
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
This is my JavaScript code which is not executing properly. I think I am getting something wrong somewhere.
I want to add a search bar to make a search option in a responsive menu navbar. However, it is showing in desktop but not in mobile menus. That's why I am using jQuery to add this manually.
$(document).ready(function() {
$('ul').append("
<li class='fusion-custom-menu-item fusion-main-menu-search fusion-last-menu-item'>
<a class='fusion-main-menu-icon'></a>
<div class='fusion-custom-menu-item-contents'>
<form action='http://www.heilmancenter.com/' method='get' class='searchform' role='search'>
<div class='search-table'>
<div class='search-field'>
<input type='text' placeholder='Search ...' class='s' name='s' value=''>
</div>
<div class='search-button'>
<input type='submit' value='' class='searchsubmit'>
</div>
</div>
<input type='hidden' value='en' name='lang'>
</form>
</div>
</li>
");
});
remove new lines from the html: either concat all lines or put your html code in one line
The first problem is that you mispelled the function keyword, the second one is that you are creating a mult-line string, but the engine doesn't know it and interprets the second line as a instruction. You need to take a precaution, such as add a backslash at the end of any line.
jQuery(document).ready(function(){
jQuery('ul').append("<li class='fusion-custom-menu-item fusion- main-menu\
-search fusion-last-menu-item'><a class='fusion-main-menu-icon'></a><div\
class='fusion-custom-menu-item-contents'><form\
action='http://www.heilmancenter.com/' method='get' class='searchform'\
role='search'>\
<div class='search-table'>\
<div class='search-field'>\
<input type='text' placeholder='Search ...' class='s' name='s'\
value=''>\
</div>\
<div class='search-button'>\
<input type='submit' value='' class='searchsubmit'>\
</div>\
</div>\
<input type='hidden' value='en' name='lang'></form>\
</div></li>");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
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.
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.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have used a template from the web for a Login page, and I am not able to figure out how can I link this page to another when one clicks the 'Login' button. I have no knowledge of HTML and CSS or JS , so if anybody can guide me through this I'll be grateful.Its for a college project that has to be submitted tomorrow. Its not that I don't want to learn, but there was something else I was working on which didn't work out pretty well so I had to start this and I have only a day.
I was unable to paste the code here. SO here's the link : http://pastebin.com/pPS0Np8A
<input type="button" value="click" onclick="window.open("http://www.google.com/"); window.open("http://www.youtube.com/");" />
If it's just a Link when pressing the button, put an <a>-tag around your button and the LInk inside the href attribute:
<p><input type="submit" value="Sign In"></p>
using harshit's solution i added the id to restore css properties but if the css value is a class rather than an id just replace id= with class=.
<input type="button" value="click" id="myCssClassId" onclick="window.open("http://www.google.com/"); window.open("http://www.youtube.com/");" />
So you were "not able to figure out how can I link this page to another when one clicks the 'Login' button".
Simplified from the login-page you provided, you have the following code:
<form action="Default5.aspx" method="POST">
<fieldset>
<p><label for="email">E-mail address</label></p>
<p><input type="email"
id="email"
value="mail#address.com"
required="required" />
</p>
<p><label for="password">Password</label></p>
<p><input type="password"
id="password"
value="password" />
</p>
<p><input type="submit" value="Login" /></p>
</fieldset>
</form>
Now, note the <input type="submit" value="Login" />. Once you'll click that, the form will submit the data contained in it (the password and email).
When you submit a form, the form needs an address where it needs to send the data to. This is then also the page that is displayed ('redirected'). You set this simply with the form's action attribute, which is just an URL.
Just wanted to rectify this for future readers.
EDIT:
So, for example an exact image-search on google could work like:
<form method="GET"
action="http://www.google.com/search"
target="_BLANK"
onsubmit="var e = this.getElementsByTagName('input');
e[1].value= 'isz:ex,iszw:' + e[3].value
+ ',iszh:' + e[4].value;
return true;
"
><fieldset>
<input type="hidden" name="tbm" value="isch" />
<input type="hidden" id="tbs" name="tbs" />
<p>Search Image:
<input type="text" name="q" value="search" />
</p>
<p>
Width: <input type="text" value="32" /> px <br />
Height: <input type="text" value="32" /> px <br />
<input type="submit" value="Search" />
</p>
</fieldset>
</form>
Example jsFiddle here
Here the method is changed from POST to GET. That way the values entered in the form are appended to the URL (so anyone can read them).
To close with a final example of how to open a new blank page I added the target-attribute, and pointed it to _BLANK.
The example's are intentionally kept simple, style and expand on them as you wish.