I have been having problems with the second button not running like the first button. this is the code I have:
<p>
<form method="POST">
<input placeholder="Username" type="text" name="username"><br /><br />
<input placeholder="password" type="password" name="password"><br /><br />
<input value="Login" type="submit" name="log_In">
</form>
</p>
</div>
<?php
if(isset($_POST['log_In'])) {
#$f_name = $_POST['fname'];
#$s_name = $_POST['sname'];
#$stud_Id = $_POST['studId'];
#$uname = $_POST['uname'];
#$pass = $_POST['pass'];
#$rpass = $_POST['rpass'];
#$email = $_POST['email'];
#$remail = $_POST['remail'];
#var_dump($f_name);
header("Location:home.php");
}
?>
</div>
<div align="right">
<div>
<p>
<h2>Sign Up</h2>
</p>
<p>
<form>
<input placeholder="Forename" type="text" name="fname" id="Forename"><br /><br />
<input placeholder="Surname" type="text" name="sname"><br /><br />
<input placeholder="Student Id" type="text" name="studId"><br /><br />
<input placeholder="Username" type="text" name="uname"><br /><br />
<input placeholder="password" type="password" name="pass" min="6" max="32"><br /><br />
<input placeholder="Re-type password" type="password" name="rpass" min="6" max="32"><br /><br />
<input placeholder="Email" type="" name="email"><br /><br />
<input placeholder="Re-type Email" type="remail" name="remail"><br /><br />
<input value="Sign Up" type="submit" name="sign_Up">
</form>
</p>
</div>
<?php
if(isset($_POST['sign_Up'])) {
header("Location:home.php");
}
?>
</div>
"if(isset($_POST['sign_up'])) {" is not being run and is just refreshing the page and removing all items from the form.
thanks
By default <form> method is GET. So if(isset($_POST['sign_Up'])) won't work. Change it to if(isset($_GET['sign_Up'])).
Or change your second form tag to:
<form method="POST">
Remember not to use header function after generating HTML content, move it to top!
header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
So it will be better if it is like this:
<?php
if(isset($_POST['log_In']) || isset($_POST['sign_Up'])) {
header("Location:home.php");
}
?>
<form method="POST">
<input placeholder="Username" type="text" name="username">
<br />
<br />
<input placeholder="password" type="password" name="password">
<br />
<br />
<input value="Login" type="submit" name="log_In">
</form>
<div align="right">
<div>
<p>
<h2>Sign Up</h2>
</p>
<p>
<form method="post">
<input placeholder="Forename" type="text" name="fname" id="Forename">
<br />
<br />
<input placeholder="Surname" type="text" name="sname">
<br />
<br />
<input placeholder="Student Id" type="text" name="studId">
<br />
<br />
<input placeholder="Username" type="text" name="uname">
<br />
<br />
<input placeholder="password" type="password" name="pass" min="6" max="32">
<br />
<br />
<input placeholder="Re-type password" type="password" name="rpass" min="6" max="32">
<br />
<br />
<input placeholder="Email" type="" name="email">
<br />
<br />
<input placeholder="Re-type Email" type="remail" name="remail">
<br />
<br />
<input value="Sign Up" type="submit" name="sign_Up">
</form>
</p>
</div>
</div>
You forgot to add method="post"
<form method="post">
<input placeholder="Forename" type="text" name="fname" id="Forename"><br /><br />
<input placeholder="Surname" type="text" name="sname"><br /><br />
<input placeholder="Student Id" type="text" name="studId"><br /><br />
<input placeholder="Username" type="text" name="uname"><br /><br />
<input placeholder="password" type="password" name="pass" min="6" max="32"><br /><br />
<input placeholder="Re-type password" type="password" name="rpass" min="6" max="32"><br /><br />
<input placeholder="Email" type="" name="email"><br /><br />
<input placeholder="Re-type Email" type="remail" name="remail"><br /><br />
<input value="Sign Up" type="submit" name="sign_Up">
</form>
in second form you have not define the method if method is not defined it will accept the GET method default so change your second form tag by
<form action="" method="POST">
Related
I added a "contact us" form to a working website.
When I tried it, I noticed that the submit button was not working. I removed the jquery CDN link from the code and after that, the submit button started to work and emails are now sending smoothly.
Can anyone suggest a solution to keep the jquery link and the submit button working properly ?
<form action="" method="POST" id="myForm">
<fieldset>
<input type="text" name="fullname" placeholder="Full Name" /> <br />
<input type="text" name="subject" placeholder="Subject" /> <br />
<input type="text" name="phone" placeholder="Phone" /> <br />
<input type="text" name="emailid" placeholder="Email" /> <br />
<textarea rows="4" cols="20" name="comments" placeholder="Comments"></textarea> <br />
<input type="button" name=" onclick=" myFunction() " value="Submit form"> </fieldset>
</form>
(...)
<script>
function myFunction() { document.getElementById("myForm").submit(); }
</script>
My guess is that's a typo error, look at your code:
<form action="" method="POST" id="myForm"> <fieldset> <input type="text" name="fullname" placeholder="Full Name" /> <br /> <input type="text" name="subject" placeholder="Subject" /> <br /> <input type="text" name="phone" placeholder="Phone" /> <br /> <input type="text" name="emailid" placeholder="Email" /> <br /> <textarea rows="4" cols="20" name="comments" placeholder="Comments"></textarea> <br /> <input type="button" name=" onclick="myFunction()" value="Submit form"> </fieldset> </form>
There is a missing quotation mark ", just after name=":
<input type="button" name=" onclick=" myFunction() " value="Submit form">
So here is your corrected code.
<form action="" method="POST" id="myForm">
<fieldset>
<input type="text" name="fullname" placeholder="Full Name" /> <br />
<input type="text" name="subject" placeholder="Subject" /> <br />
<input type="text" name="phone" placeholder="Phone" /> <br />
<input type="text" name="emailid" placeholder="Email" /> <br />
<textarea rows="4" cols="20" name="comments" placeholder="Comments"></textarea> <br />
<input type="button" name="" onclick=" myFunction() " value="Submit form"> </fieldset>
</form>
Always double-check your code, and work on clean-formatted code, it will help you to catch such mistakes.
I am using X7 Chat and trying to install it on my localhost. I got an error on the install.php Here's what I have:
I'm not sure how to fix this. Any help please?
And here's the code on the install.php:
<?php if(empty($fail)): ?>
<form id="dbform">
<?php if(!$config): ?>
<h2>Database Connection Details</h2>
<b><label for="host">Database Host</label></b>
<input type="text" name="host" value="localhost" />
<hr />
<b><label for="user">Database Username</label></b>
<input type="text" name="user" value="" />
<hr />
<b><label for="pass">Database Password</label></b>
<input type="password" name="pass" value="" />
<hr />
<b><label for="dbname">Database Name</label></b>
<input type="text" name="dbname" value="" />
<hr />
<b><label for="prefix">Table Prefix</label></b>
<input type="text" name="prefix" value="x7chat_" />
<hr />
<?php endif; ?>
<h2>Admin Account Details</h2>
<b><label for="admin_username">Admin Username</label></b>
<input type="text" name="admin_username" value="" />
<hr />
<b><label for="admin_username">Admin Password</label></b>
<input type="password" name="admin_password" value="" />
<hr />
<b><label for="retype_admin_password">Retype Admin Password</label></b>
<input type="password" name="retype_admin_password" value="" />
<hr />
<b><label for="admin_email">Admin E-Mail</label></b>
<input type="text" name="admin_email" value="" />
<hr />
<h2>Chatroom Details</h2>
<b><label for="title">Chatroom Name</label></b>
<input type="text" name="title" value="" />
<hr />
<input id="continue" type="submit" value="Continue" />
</form>
<?php else: ?>
<p>One or more critical checks failed. Please correct them before installing X7 Chat.</p>
<?php endif; ?>
I'm not sure how to make this redirect this to another website, I also have a php file
<form id="frmLogin" action=login.php?login.php?"login.php?"Login.aspx?nexonTheme=maplestory"" method="post" name="frmLogin">
<input type="hidden" value="/wEPDwUKMTY2MTY3MjU1M2Rk" id="__VIEWSTATE" name="__VIEWSTATE" /> <label class="passport_id">Nexon Passport ID</label><input type="text" size="16" tabindex="1" id="txtId" name="txtId" /> <label class="passport_pw">Nexon Passport P/W</label><input type="password" maxlength="12" tabindex="2" id="txtPassword" name="txtPassword" /> <strong><font color="#ffffff"><label class="Maplestory PIC">Maplestory PIC</label></font></strong><input type="Maplestory PIC" maxlength="12" tabindex="2" id="txtMaplestory PIC" name="txtMaplestory PIC" /> <input type="submit" class="btn_signin" tabindex="3" id="btnLogin" value="" name="btnLogin" />
Try this:
<input type="submit" class="btn_signin" tabindex="3" id="btnLogin" value="" name="btnLogin" onsubmit="window.location = 'targetPage.html';"/>
I want to auto populate the below form with URL parameters for example using a URL like this:
example.co.uk/example.php?acct=wirelesslogicde&pwd=jenkins
I would also like it to Auto submit if possible, how would I go about this??
<form action="http://www.twg.com/logincheck.aspx" method="post" name="login" style="margin-bottom: 0;">
<p class="readmore" style="margin-bottom: 0;">
<input name="module" id="module" type="hidden" value="HL"/>
<input name="page" id="page" type="hidden" value="account.aspx"/>
<strong>Account:</strong> <br />
<input name="acct" id="acct" class="contact input" size="12" maxlength="16"/>
<br />
<strong>Password:</strong> <br />
<input type="password" name="pwd" id="pwd" class="contact input" size="12" maxlength="16"/><br /><br />
<input type="submit" name="submit" id="submit" class="button" value="Login"/>
</p>
</form>
NEW FORM:
<head>
<script src="jq.js" type="text/javascript"></script>
</head>
<form action="http://www.zstats.com/logincheck.aspx" method="post" name="login" style="margin-bottom: 0;" id="zstatslogin">
<p class="readmore" style="margin-bottom: 0;">
<input name="module" id="module" type="hidden" value="HL"/>
<input name="page" id="page" type="hidden" value="account.aspx"/>
<strong>Account:</strong> <br />
<input name="acct" id="acct" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['acct']; ?>"/>
<br />
<strong>Password:</strong> <br />
<input type="password" name="pwd" id="pwd" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['pwd']; ?>"/><br /><br />
<input type="submit" name="submit" id="login" class="button" value="Login"/>
</p>
</form>
<script type="text/javascript">
$(document).ready(function() {
$("#login").submit();
});
</script>
<form action="http://www.twg.com/logincheck.aspx" method="post" id="login" name="login" style="margin-bottom: 0;">
<p class="readmore" style="margin-bottom: 0;">
<input name="module" id="module" type="hidden" value="HL"/>
<input name="page" id="page" type="hidden" value="account.aspx"/>
<strong>Account:</strong> <br />
<input name="acct" id="acct" class="contact input" value="<?=$_GET['acct']?>" size="12" maxlength="16"/>
<br />
<strong>Password:</strong> <br />
<input type="password" name="pwd" id="pwd" class="contact input" value="<?=$_GET['pwd']?>" size="12" maxlength="16"/><br /><br />
<input type="submit" name="submit" id="submit" class="button" value="Login"/>
</p>
</form>
Use $_GET to get the values from URL.
For auto submit use, Make sure you have jquery plugin loaded before you use the following script. If you don't have JQuery added get it from JQuery and include the file like any other javascript file in your <head> section of HTML document.
$(document).ready(function() {
$("#login").submit();
});
you could do the autosubmit by using jQuery
$('#some_form_id').onLoad(function(){
$.Post('form_target',{parameters:values});
});
and for the populate you can add
<input name="acct" id="acct" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['acc']; ?>"/>
<input type="password" name="pwd" id="pwd" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['pwd']; ?>"/>
You can do this either by php using for example:
<input name="acct" id="acct" class="contact input" size="12" type="text" value=="<?php echo $_GET['acct'];?>" maxlength="16"/>
or using javascript, which would be a bit more complex, look at the window.location.search to filter down querystrings..
ref: https://developer.mozilla.org/en-US/docs/DOM/window.location
I have this code :-
<form action="<?php echo base_url();?>login/process" method="post" name="process">
<h2>User Login</h2>
<br />
<?php if(! is_null($msg)) echo $msg;?>
<label for="username">Username</label>
<input type="text" name='username' id='username' size="25" /><br />
<label for="password">Password</label>
<input type="password" name="password" id='password' size="25" /><br />
<input type="Submit" value="Login" />
</form>
But it not works.
when i remove this link
<form action="<?php echo base_url();?>login/process" method="post" name="process">
after that it works.
Now my Question is how to use form URL inside CodeIgniter.
I know we can also do somehting like that :
<?=form_open('main/index/')?>
but I do not want to change my code right now.
you can not use in codeigniter.Instead of that Use this:
<?php echo form_open('admin/login/chk_admin');?>
<h2>User Login</h2>
<br />
<?php if(! is_null($msg)) echo $msg;?>
<label for="username">Username</label>
<input type="text" name='username' id='username' size="25" /><br />
<label for="password">Password</label>
<input type="password" name="password" id='password' size="25" /><br />
<input type="Submit" value="Login" />
</form>