i am trying to make the login form in my website appears in the middle of the page with gray background, so i have done it like that:
<style type="text/css">
#cover5{position:absolute;top:0px;left:0px;overflow:hidden;display:none;width:100%;height:100%;background-color:gray;text-align:center}
#warning{top: 150px;margin:auto;position:relative;width:600px;height:fit-content;background-color:white;color:black;padding:10px; zIndex:20; border: 5px solid #003366;}
</style
<div id="cover5" onclick="javascript:cover5();">
<div id="warning" onclick="javascript:cover5();">
<?php include 'SignIn.php'; ?>
</div>
</div>
<script>
function cover5()
{
var cover=document.getElementById('cover5');
if(vis)
{
vis=0;
cover.style.display='block';
}
else
{
vis=1;
cover.style.display='none';
}
}
</script>
an this the code of the SignIn.php
<form id='login' action='SignIn.php' method='post' accept-charset='UTF-8' onsubmit="return valid()">
<fieldset >
<legend>SignIn</legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<label for='username' >Email:</label>
<input type='text' name='email' id='username' maxlength="50" /> <br />
<label for='password' >Password:</label>
<input type='password' name='password' id='password' maxlength="50" /> <br />
<input type='submit' name='Submit' value='Login' /> <br />
<a href='resetPassword1.php'> Forgot/Reset Password? Click Here</a>
</fieldset>
</form>
the problem is that when use clicks on Forgot/Reset Password? or enter wrong data everything opens in new window, i have used iframe instead of div however when the use signIn successfully the home page opens in the same iframe, so anyone know how to solve the problem?
sorry for the long question :)
You need to add this to your link:
target='_self'
so it would look like this:
<a href='resetPassword1.php' target='_self'> Forgot/Reset Password? Click Here</a>
there are others you can play with too, like to open in new window:
target='_blank'
hope this helps
inside of the link try setting target="_self" so
Forgot/Reset Password? Click Here
If that doesn't work try it in another browser. Sometimes browsers have default settings that could mess stuff up. Another possible problem may be Javascript somewhere in your site sending your links to new windows.
Related
I am losing functionality when I change from an image to a simple button. This is the code when it is an image and it submits:
$form= "
<form method='post' action='/login.php'>
<b>Name:</b><br><input type='text' name='name'
size='19' class='login'><br><b>Password:</b><br><input
type='password' name='password' size='19' class=
'login'><br>
<img src='/layout/blank.gif' height='6' width='1'
alt='blank'><br>
<input type='hidden' name='redir' value='$redir'>
<input type='image' src='/layout/loginword.gif' name=
'action' value='Go' style='vertical-align: middle;'
title='Login'> (<a href='/lostdetails.php' class=
'menu'>Lost Details?</a>)
</form>";
When edited to display a button instead of an image as below I lose the functionality:
$form= "
<form method='post' action='/login.php'>
<b>Name:</b><br><input type='text' name='name'
size='19' class='login'><br><b>Password:</b><br><input
type='password' name='password' size='19' class=
'login'><br>
<img src='/layout/blank.gif' height='6' width='1'
alt='blank'><br>
<input type='hidden' name='redir' value='$redir'>
<input type='button' name=
'action' value='Go' style='vertical-align: middle;'
title='Login'> (<a href='/lostdetails.php' class=
'menu'>Lost Details?</a>)
</form>";
This is occuring because input type="image" has the same functionality of a submit button, while input type="button" does not have any implicit functionality. (It is just a dumb clickable button)
You need to change it to input type="submit"
Don't use type="button" in the submitting input! Try to use type="submit" in that "Go" field.
That's because the first attribute value prompt to the browser that the button is literally a normal object which doesn't have nothing to do with that form. Maybe you can use it as a link, or a Javascript event caller ... but not as the submitting action.
So the new code will be:
<form method='post' action='/login.php'>
<b>Name:</b><br><input type='text' name='name'
size='19' class='login'><br><b>Password:</b><br><input
type='password' name='password' size='19' class=
'login'><br>
<img src='/layout/blank.gif' height='6' width='1'
alt='blank'><br>
<input type='hidden' name='redir' value='$redir'>
<input type='submit' name=
'action' value='Go' style='vertical-align: middle;'
title='Login'> (<a href='/lostdetails.php' class=
'menu'>Lost Details?</a>)
</form>
Obviously you can put it in you PHP variable, your choice. If you want to learn more about HTML buttons, here you can see the W3Schools documentation about it.
Andrea
you should use type="submit"
and if you want to use the button,
you should use the button tag
with type="submit"
I currently have this login page.
<form action='http://localhost:8080/iSchedj/API/api.php' method='post'>
<fieldset>
<p>
<label for='username'>Username</label>
<input type='text' id='username' name='username' value='' maxlength='20' />
</p>
<p>
<label for='password'>Password</label>
<input type='password' id='password' name='password' value='' maxlength='40' />
</p>
<p>
<input type='hidden' name='form_token' value='<?php echo $form_token; ?>' />
<input type='submit' name='login' id='login' value='Login' />
</p>
</fieldset>
</form>
On submit, I have a function on the server-side where I analyze the data and check if there are any issues.
Problem is, I would like to send a response back to the client and re render the login page if any issues occurred with a response saying 'Error on login'.
I am having an issue with the response part.
On the server side, I just run this when an error is found in the form
header( 'Location: http://localhost:8080/iSchedj/index.php');
echo 'Incorrect Length for Password';
which redirects the client to the login page. But how do I send the error message to the page as well? The echo message is no where to be found.
Add it to the URL and display your error message via JavaScript.
header( 'Location: http://localhost:8080/iSchedj/index.php#error=1');
Your JS script will need to look at the document.location.hash and behave accordingly.
I'm trying to build a php contact form (to be used into a wordpress custom page) that show a different "thank you message" based on the checkbox selection.
There will be three checkbox, every checkbox in used will make appear a download link under the "thank you" message.
<form method="post" action="php/contact-send.php" id="contact_form">
<p><label class="form_label" for='form_name'>Name</label>
<input id='form_name' type='text' name='name' class="textbox" value='' /></p>
<p><label class="form_label" for='form_email'>E-mail</label>
<input id='form_email' type='text' name='email' class="textbox" value='' /></p>
<p>Download1 <input id='form_name' type='checkbox' name='Download1' class="textbox" value='Download1' /></p>
<input id='form_submit' type='submit' name='submit' value='Send message' />
<!-- To Email -->
<input id='to_email' type='hidden' name='to_email' value='<?php echo "";?>' />
<!-- hidden input for basic spam protection -->
<div class='hide'>
<label for='spamCheck'>Do not fill out this field</label>
<input id="spamCheck" name='spam_check' type='text' value='' />
</div>
</form>
<!-- contact form ends here-->
<!-- This div will be shown if mail was sent successfully -->
<div class="hide success">
<p><?php echo thanks_message;?></p>
<p>
<?php
if(isset($_POST['Download1'])) {
// The checkbox was enabled...
echo "Link download 1";}
else { echo "much wrong, wow";}
?>
</p>
The problem is i can't get it to work and detect when the first checkbox is selected, it alway give me the else message even if i select it. I'm kinda new with php and i don't really get what i'm doing wrong,
Thanks in advance for any help
I have a password element which I use for signing in process. But, I get this weird username and password once the page gets opened !!
but the problem is when I don't user password element but only input I don't get this weird username and password, what should I do to make them blank?
Here's the code
echo"
<center><small>
<br />
<p> Welcome Guest you can sign in here:</p></br>
<form action = \"HomeWork.php\" method = \"post\">
User name*: <input type=\"text\" name=\"Username\" />
Password*: <input type=\"password\" name=\"Password\" />
or Sign up !
<br /> <br />
<input type=submit value=Submit align=\"middle\" />
</form>
</small></center>";
Can you help me??
This is your browser remembering the username/password you've entered in for your localhost site. This isn't to do with your html or php. To test, try it out in another browser that you have used to view the localhost site and see if it adds it to the form elements.
EDIT
Note, following kag's answer, you can add autocomplete=off to the form to prevent the browser from autocompleting.
https://developer.mozilla.org/en/how_to_turn_off_form_autocompletion
echo "
<center>
<small>
<br />
<p>Welcome Guest you can sign in here:</p></br>
<form action='HomeWork.php' method='post' autocomplete='off'>
Username*: <input type='text' name='Username' />
Password*: <input type='password' name='Password' />
<a href='Signup.php'>or Sign up !</a>
<br />
<input type='submit' value='Submit' align='middle' />
</form>
</small>
</center>
";
Also, consider not using tags like center and small; instead use css and classes/selectors.
This is your browser trying to help you by automatically filling the fields for you. If you want to stop it from doing so, you can add autocomplete="off" in both <input>.
Try adding the "value" attribute to the input tags and set it to empty:
<input type="text" name="Username" value="" />
If that doesn't do it, try using javascript:
<head>
<script type="text/javascript">
function clearMyFields() {
document.getElementById('input_u').value = "";
document.getElementById('input_p').value = "";
}
</script>
</head>
<body onload="clearMyFields();">
<input type="text" id="input_u" name="Username" value="" />
<input type="password" id="input_p" name="Password" value="" />
Try with:
<meta http-equiv="Pragma" content="no-cache">
<!-- Pragma content set to no-cache tells the browser not to cache the page
This may or may not work in IE -->
and
<meta http-equiv="expires" content="0">
<!-- Setting the page to expire at 0 means the page is immediately expired
Any vales less then one will set the page to expire some time in past and
not be cached. This may not work with Navigator -->
i have a form with a textarea and a button. if the button is clicked while the textarea is empty, the form will reload and generate an error message. otherwise, the form will redirect to another page. now, i integrated a jquery dialog box. when the button is clicked the dialog box should appear and ask a yes or no question. the problem is when i click the button the dialog box appears but disappears after a few seconds. how can i fix this? i'm using php for the form and jquery for the dialog box.
ps. in php, when you click a button in a form the page will reload right? i think this has something to do with the disappearing of the box because it disappears right before it reloads.
here's my code
<form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>" enctype="multipart/form-data" onsubmit="myRedirect();">
<p class="style16">
<div align="left">
<p><span class="style5">Rules:</span>
<?
if($_POST['continue']) {
if($_POST['rules']==null) {
echo $_SESSION['nature']."<font color='red' size='3'><b>Please enter the rules.</b></font><br>";
}
}
?>
<input type="hidden" name="other_id" value="<? echo $_SESSION['other_id']; ?>">
<input type="hidden" name="hidden1" value="<? echo $_SESSION['hidden1']; ?>">
</p>
<p>
<textarea name="rules" rows="7" cols="49"></textarea>
<br />
</p>
<div id="dialog" title="Empty the recycle bin?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Is the judge/speaker/facilitator from UST?</p>
</div>
<p><input type="submit" name="continue" id="continue" value="Continue"/>
<input type="reset" name="clear" value="Clear"></p>
<center>
<!--<input type="submit" name="clear2" id="clear2" value="Clear" onClick="textfield.value="" textfield2.value="" textarea.value="" textarea2.value=""
textarea3.value="" textarea4.value="" textarea5.value="" textarea6.value="" file.value="" "/>-->
</center>
</p>
</div>
</form>
To keep the form from submitting, you need a "return false" in its onsubmit event.