Why do you want to send two different names for your input boxes? Can't you just copy the values to the other variable on the backend?
$_POST['login'] = isset($_POST['user_usr']) ? $_POST['user_usr'] : "";
Why do you want to send two different names for your input boxes? Can't you just copy the values to the other variable on the backend?
$_POST['login'] = isset($_POST['user_usr']) ? $_POST['user_usr'] : "";
Never used that way before, so i'm not sure how to send the login and the user_usr together.
The code i created is working for the site now, but the forum still isn't logged on.
Can you please take a look at it and make some minor changes??
Thanks,
Marc
<form action="index.php?action=login" method=post>
<table width=100%>
<tr>
<td><small>Naam</small></br><input type="text" name="login" $_POST['login'] = isset($_POST['user_usr']) ? $_POST['user_usr'] : ""; ></td>
<td><small><a href="index.php?page=forget_password">Wachtwoord</a></small><br><input type="password" name="pswd" size="10" $_POST['pswd'] = isset($_POST['password']) ? $_POST['password'] : ""; ></td>
</tr>
<tr>
<td><small><a href="index.php?page=register">Registreren</a><small></td >
<td align="right"><button type="submit">Log aan</button></td>
</tr>
<tr>
<td colspan=2><small>{$loginErrortxt}</small></td>
</tr>
</table>
<input type=hidden name="mode" value="login">
</form>
I meant use that on index.php where you check the login and password. If you are trying to name a text box with two names then the values are always going to be the same, correct? So when you check the value after the form is submitted you can set the user_usr variable equal to whatever was submitted in the login box.
I am also stuck in the same situation.
JohanFahey After nineteen and a half years?
I am not sure what you are trying to do here.
But you can capture and send as many input fields as you like back to the server where you can
use the data for whatever purpose you wish one of which could be to authenticate a login.
I see that you are using an input of type "submit" which renders as a button control.
When the user clicks this button it will immediately submit the form in its current state
whether it is completed or not ie: do a postback.
If you want to make sure that all the inputs you need have been completed
and are of the correct data type or format you can use an HTML Button tag
with an onclick event handler that triggers a client side script function that is
designed to validate the inputs in order and alert the user that there is
a problem with an input so that the user can correct the input and resub the form.
The last thing this function needs to do once all inputs are deemed valid
is to submit the form using :
document.forms[0].submit();
In order to do this, of course, you would need to assign the "id" property
to the form and input tags so that they render as objects in teh browser and can
therefore be accessed by the client side scipting.
You can use use client side Javascript or VBScript for scripting but there
are synctax differences between the two.
Are you familiar with client side scripting techniques? If not you should work
on them.
You can also validate form data serverside if necessary but that's a little more
complicated and may involve multiple postbacks.
Marc
Just knocked this out by way of example of what I posted previously
Two pages . loginpage.php and adminpage.php
There are many ways of doing this. This is just one example.
loginpage.php
<?php
session_start();
date_default_timezone_set("Europe/London");
?>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<script type="text/javascript">
function subForm(){
subfrm = true;
if (name1Obj.value == ""){
alert("Please enter Name Part 1");
name1Obj.focus();
subfrm=false;
return;
}
if (name2Obj.value == ""){
alert("Please enter Name Part 2");
name2Obj.focus();
subfrm=false;
return;
}
if (pwordObj.value == ""){
alert("Please enter Password");
pwordObj.focus();
subfrm=false;
return;
}
if (subfrm==true){
// post to next page
formObj.action="adminpage.php";
formObj.submit();
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="adminpage.php" id="form1">
<div>
<span id="Label1" style="display:inline-block;height:16px;width:50px;left: 305px; position: absolute;
top: 109px; padding-left: 0px; padding-bottom: 0px; margin: 0px; vertical-align: middle; text-indent: 0px; padding-top: 0px; text-align: left;">Part 2</span>
<span id="Label1" style="display:inline-block;height:16px;width:173px;left: 73px; position: absolute;
top: 109px; padding-left: 0px; padding-bottom: 0px; margin: 0px; vertical-align: middle; border-top-style: none; text-indent: 0px; padding-top: 0px; border-right-style: none; border-left-style: none; letter-spacing: normal; text-align: left; border-bottom-style: none;">Username Part 1</span>
<input name="username1" type="text" value="" maxlength="16" id="username1" tabindex="1" style="width:100px;left: 190px; vertical-align: middle;
direction: ltr; text-indent: 3px; letter-spacing: normal; position: absolute;
top: 104px; height: 20px; text-align: left; z-index: 105;" />
<input name="username2" type="text" value="" maxlength="16" id="username2" style="width:100px;left:350px; vertical-align: middle;position: absolute;
top: 104px; height: 20px; text-align: left;" />
<input name="pword" type="text" value="" maxlength="1000" id="pword" tabindex="2" style="width:100px;left: 190px; vertical-align: middle;
direction: ltr; text-indent: 3px; letter-spacing: normal; position: absolute;
top: 132px; height: 20px; text-align: left; z-index: 103; bottom: 305px;" />
<button id="loginButton" onclick="javascript:subForm();return false;" style="left: 190px; position: absolute; top: 170px; z-index: 107; width:200px; height:25px;">Log in</button>
<span id="Label2" style="display:inline-block;height:16px;width:71px;left: 73px;
vertical-align: middle; text-indent: 0pt; letter-spacing: normal; position: absolute;
top: 135px; text-align: left; z-index: 104;">Password</span>
</div>
</form>
<script type="text/javascript">
formObj = document.getElementById("form1");
name1Obj = document.getElementById("username1");
name2Obj = document.getElementById("username2");
pwordObj = document.getElementById("pword");
</script>
</body>
</html>
adminpage.php
<?php
session_start();
date_default_timezone_set("Europe/London");
$username1 = "NOT SET";
$username2 = "NOT SET";
$password = "NOT SET";
$contlen = $_SERVER['CONTENT_LENGTH'];
if ($contlen > 0){
$username1 = $_REQUEST['username1'];
$username2 = $_REQUEST['username2'];
$password = $_REQUEST['pword'];
}
?>
<!DOCTYPE html>
<html>
Admin Page
<table>
<tr><td>User name Part 1</td><td><?=$username1 ?></td></tr>
<tr><td>User name Part 2</td><td><?=$username2 ?></td></tr>
<tr><td>Password</td><td><?=$password ?></td></tr>
<tr><td colspan="2">Do what you need to do with this data</td></tr>
</table>
</html>
Weedpacket
According to JohnFahey, as of 4 days ago, he has the same problem.
This is why the item was elevated to the top of the list where I could see it.
My response might be relevant in his case too.
RayPooley Then replying to @JohanFahey would have sent the notifications of your replies in a more useful direction. Also, @JohanFahey could have started a new thread with more relevant detail, although that would have course required writing more than seven words.
Weedpacket
The item was at the top of the list.
In my eagerness to assist the OP I didn't notice the original posting date.
I responded in an effort to assist the OP by making a contribution suggesting a possible way forward.
Member contributions on sites like this one not only assist OPs but are also available for future reference by other members.
This is usually how sites like this one become a valuable resource for future members provided that the information remains on the site.
At least that is my understanding on how these things work.
So I really don't know why you have a problem with it and why you are making such a big deal of it.
I presume 4 days ago @JohanFahey performed a key word search on the internet and arrived at this thread by some path or other.
That's because it is still in the database 19 years after it was posted.
That's alway going to be a possibility so I don't know why it warrants special attention when it happens.
But it's just another thread inviting members to comment.
Of course, if it's problematic then the way to prevent it in the first place is to delete or archive threads beyond a certain date.
That's a management decision to make and a task for management to perform.
The membership don't have ability to do anything about that.
People come here to either help others or seek help from others. I came here to help.
If you find the way I help to be problematic then I am more than happy to stop helping and cancel my account.
Let me know your preference or perhaps cancel it for me if you prefer.
RayPooley
Not at all. The original post had a specific problem, and there was a reply, there was still a problem (in one case it looks like @Marc failed to start a PHP context, unless this is an excerpt from a heredoc statement; and in the other forgot to provide the value
attribute with its value
name). That was replied to and the issue died the death. Twenty years later someone blurted out that they're "stuck in the same situation", which would appear to be "it's working but the forum still isn't logged on".
Someone landing on this thread might think it relevant to their situation and continue reading long enough to find your reply. But there's no indication that the one person who did and resurrected the thread would have. I'm just pointing out you may be shouting into the void.