There is problem in submitting the form. My form tag looks like-
<form method="post" action="classes/action.php" >
this doesn't redirect the page..
Any idea??
more code-
<div class="grid_12">
<div class="grid_6 half-c half_m2" align="center" style="border-radius:100px 0 0 100px">
<form method="post" action="classes/action.php">
<table>
<tr>
<th colspan="2"><label class="eh1 eh1m">Login as Visitor</label> </th>
</tr>
<tr>
<td><br /></td>
<td></td>
</tr>
<tr>
<td><label class="eh2">Username</label></td>
<td><input type="text" name="txtVUname" class="etxt1 etxtm1"/></td>
</tr>
<tr>
<td><label class="eh2">Password</label></td>
<td><input type="password" name="txtVPwd" class="etxt1 etxtm1"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnVLogin" value="Login" style="float: right" /></td>
</tr>
</table>
</form>
</div>
<div class="grid_6 half-c half_m2" align="center" style="border-radius:0 100px 100px 0">
<form method="post" action="classes/action.php" >
<table>
<tr>
<th colspan="2"><label class="eh1 eh1m">Login as a Company</label></th>
</tr>
<tr>
<td><br /></td>
<td></td>
</tr>
<tr>
<td><label class="eh2">Username</label></td>
<td><input type="text" name="txtCUname" class="etxt1 etxtm1"/></td>
</tr>
<tr>
<td><label class="eh2">Password</label></td>
<td><input type="password" name="txtCPwd" class="etxt1 etxtm1"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnComLogin" value="Secure Login" style="float: right" /></td>
</tr>
</table>
</form>
</div>
</div>
folder structure looks like--
mysite.com
- classes
- action.php
- login.php (containing form)
one more thing.. i can do the same from another page having form and a submit button to redirect on classes/action.php page
You can try this
<form method="post" action="./classes/action.php">
Be careful that file names are case-sensitive in unix!
very simple mistake only. Replace form action and say me the result
<form method="post" action="../mywebsitename/classes/action.php" >
change the action.php to action2.php and try
<form method="post" action="../mywebsitename/classes/action2.php" >
You should return back by .. So if your form file in the same folder contains the classes folder your code will work, if your form file in internal folder like files/form_file.PHP and the folder files in the same classes folder your code will be:
<form method="post" action="<?php echo $_SERVER['HTTP_HOST']; ?>/classes/action.php" >
And so on.
Related
Query 1.
form submitting working fine in local , but not working in live. I removed the action and put # and also i didn't call any script for redirect but while click the submit button it is automatically redirect to the same page. i don't know how it is redirecting ?
Query 2.
In action i mentioned <?php echo $_SERVER['PHP_SELF']; ?> and also gave direct url . if i print the post value it is not coming to POST .
In both ways it is showing the error
This page isn’t working
www.XXXXXXXXXXX.com didn’t send any data.
here below i paste my short code
<?php
ob_start();
session_start();
$_SESSION['captcha'] = rand(1000,9999);
include("./config/dbconnect.php");
include("./functions/functions.php");
if($_POST){
print_r($_POST); exit;
}
?>
<table border="0" width="100%"><tr><td style="padding-left:25px">
<form name="register" method="post" action="#" enctype="multipart/form-data">
<table width="634" border="0">
<tr>
<td colspan="3" class="sub_heading"><div align="right"><span class="style_r">* Mandatory Fields</span></div></td>
</tr>
<tr>
<td height="24" colspan="3"><div align="left" class="sub_heading">Login Information</div></td>
</tr>
<tr>
<td width="178">Email<span class="style_r">*</span></td>
<td width="10">:</td>
<td width="432"><input type="text" name="email" width="14" maxlength="50" /></td>
</tr> ******************* etc <tr>
<td colspan="3"><input type="checkbox" name="terms" />
I have read, understood and agree to the Terms and Conditions of eGulfCareers.com</td>
</tr>
<tr>
<td width="178"></td>
<td width="10"></td>
<td width="432"><input type="hidden" name="register" value="1" />
<input type="submit" name="submit" value="Signup" class="submit_button" /></td>
</tr>
</table>
</form></td>
</tr>
</table> `
I'm trying to do a remember me. I'm having an issue were the cookie isn't setting after a form action redirect.
I know this is not the safest way to store a password but it does matter because this is just a simple page that has no information that is important.
if(isset($_POST['signin']))
{
setcookie("cid",$id,time()+60*60);
setcookie("cpass",$pass,time()+60*60);
}
?>
<body>
<form action="login.php" method="post">
<hr/>
<table align="center">
<tr>
<td colspan="2" align="center"><?php echo #$err;?></td>
</tr>
<tr>
<th>Your email</th>
<td><input type="text" name="username" placeholder="username" value="<?php echo #$_COOKIE['cid'];?>" required/></td>
</tr>
<tr>
<th>Your password</th>
<td><input type="password" placeholder="password" name="password" value="<?php echo #$_COOKIE['cpass'];?>" required/>
</td>
</tr>
<tr>
<th>Stay Signed In</th>
<td><input type="checkbox" name="ch"/></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="signin" value="SignIn"/></td>
</tr>
</table>
</form>
</body>
Add this lines in,
if(isset($_POST['signin']))
{
setcookie("cid",$id,time()+60*60);
setcookie("cpass",$pass,time()+60*60);
}
?>
in login.php
Since your action of the form is login.php.
</table>
</form>
This is also wrong, it should be
</form>
</table>
Ok so im making a login system and for some reason when typed like this im getting issues with it posting without an echo or print and the following script the displays itself help anyone.
<?PHP $form = '
<form method="POST" action="login.php">
<table>
<tr>
<td>Username:<td>
<td><input type="text" name="user"><td>
</tr>
<tr>
<td>Password:<td>
<td><input type="password" name="password"><td>
</tr>
<tr>
<td><td>
<td><input type="submit" name="loginbtn" value="Login"><td>
</tr>
<tr>
<td>Register<td>
<td>Forgoten Password<td>
</tr>
</table>
</form>'
;
?>
<?php //Some PHP Code if necessary
if(true) { //Any html between this brace and the next brace will be included
?>
<form method="POST" action="login.php">
<table>
<tr>
<td>Username:<td><td>
<input type="text" name="user">
<td>
</tr>
<tr>
<td>Password:<td><td>
<input type="password" name="password">
<td>
</tr>
<tr>
<td><td><td>
<input type="submit" name="loginbtn" value="Login">
<td>
</tr>
<tr>
<td>Register<td><td>Forgoten Password<td>
</tr>
</table>
</form>
<?php
} //End of if statement.
else { //This won't be shown, because the if statement is always true
?>
<div>
This is not displayed
</div>
<?php
}
?>
My form is not submitting, My database insert class works and I have tested. But my form seems not to want to submit or post values from my form. Is there something I left out?
<form name="form1" method="post" action="sub_newsletter.php" enctype="multipart/form-data">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">Newsletter</td>
</tr>
<tr>
<td>Name : </td>
<td><input name="name" type="text"></td>
</tr>
<tr>
<td>Email : </td>
<td><input name="email" type="text"></td>
</tr>
<tr>
<td> <input type="text" name="check_spam" id="check_spam" size="30" style="display:none;" /> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><input type="image" name="submit" src="images/sub.jpg" style="width:180px; height:70px;"></td>
</tr>
</form>
</table>
My submit script
<?php
include('includes/database.php');
include('includes/settings.php');
include('includes/newsletter.php');
if (isset($_POST['submit'])){
//to check if posting
echo $username=rtrim($_POST['name']);
echo $myemail=rtrim($_POST['email']);
//
$check=$_POST['check_spam'];
if(!empty($check)){ echo "You are spam"; } else{
$username=rtrim($_POST['name']);
$myemail=rtrim($_POST['email']);
$news = new Newsletter();
$new->first_name=$username;
$new->email=$myemail;
$new->create();
echo "<script>alert(\"Thank you for your subscription\"); </script>";
echo "<script>window.location.replace(\"index.html\"); </script>";
}
}
?>
You obviously missed submit button
<input type="submit" name="submit">
Since you have already a field with that name, just change it or use a different name.
Here is the form that is confusing me
<h1>
Login
</h1>
<form action="" method="post">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="user" maxlength="30">
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type="password" name="pass" maxlength="30">
</td>
</tr>
<tr>
<td colspan="2" align="left">
<input type="checkbox" name="remember">
<font size="2">
Remember me next time
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" name="sublogin" value="Login">
</td>
</tr>
<tr>
<td colspan="2" align="left">
Join
</td>
</tr>
</table>
</form>
I got the code from this tutorial and it works fine but i cant seem to understand where a/the form submit too if no action is present
If action is set to "" or if the action attribute is missing, the form submits to itself. That is, if your script is index.php, your form submits to index.php.
If the form's action attribute is either set to "" OR not specified, it will still default to action="self", thus the form will send to the address of the document containing the form.
So,
<form method="post">
<!-- IS THE SAME AS... -->
<form action="" method="post">
<!-- IS THE SAME AS... -->
<form action="self" method="post">
(Try it)
For reference, see the HTML standard 4.10.18.3 #8:
http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-submission-algorithm
default action for form submission is METHOD="GET" and ACTION="SELF"
you should use a form name
if the action is empty then it posts to itself.