Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with if then else statement, i'm newbie

Status
Not open for further replies.

taz97

Programmer
Jun 7, 2001
17
CA
Hi, sorry for my english, i'm french canadian !
I have a html file asking login and password and after that I send the data to this asp file. I have some problem, if you can help me !!
Thanks, also, i would like to dispatch the user in her personal page but I don't know how !


<%
DIM login
DIM password

login = Cstr(request.form(&quot;login&quot;))
password = Cstr(request.form(&quot;password&quot;))


if (login=&quot;rros017&quot; and password=&quot;osaka98a&quot;) then
**** WANT TO GO TO rros017.html, HOW TO DO ?
elseif (login=&quot;rdus019&quot; and password=&quot;repas03n&quot;) then
**** WANT TO GO TO rdus019.html, HOW TO DO ?
else
alert(&quot;Wrong password!&quot;)

end if

%>
 
If your problem is that you are not able to retrieve the data in the login and password variables make sure the page that is padding them uses the &quot;post&quot; method.


To send the user to their own page

if (login=&quot;rros017&quot; and password=&quot;osaka98a&quot;) then
**** WANT TO GO TO rros017.html, HOW TO DO ?
response.redirect (login & &quot;.html&quot;)
elseif (login=&quot;rdus019&quot; and password=&quot;repas03n&quot;) then
**** WANT TO GO TO rdus019.html, HOW TO DO ?
response.redirect (login & &quot;.html&quot;)
else
alert(&quot;Wrong password!&quot;)

end if
 
Sorry, didn't see the alert try this

<%@ Language=VBScript %>
<%
DIM login
DIM password

login = request.form(&quot;login&quot;)
password = Request.Form(&quot;password&quot;)


if (login=&quot;rros017&quot; and password=&quot;osaka98a&quot;) then
'**** WANT TO GO TO rros017.html, HOW TO DO
Response.Redirect(login & &quot;.html&quot;)
elseif (login=&quot;rdus019&quot; and password=&quot;repas03n&quot;) then
'**** WANT TO GO TO rdus019.html, HOW TO DO ?
Response.Redirect(login & &quot;.html&quot;)
else
%>
<Script language=Javascript>alert(&quot;Wrong password!&quot;);</Script>
<%
end if
%>
 
This is my html file.
This file call the asp file.
Also, I tried the hint of qwe1204 and it's not run !
thanks for your help

<body>
<script language=&quot;JavaScript&quot;>

function espacevide()
{
if (document.formu.login.value == &quot;&quot;)
{
alert(&quot;Vous devez inscrire votre login s.v.p.&quot;)
document.formu.login.focus();
return false;
}
document.formu.submit();
}

// --></script>

<form action=&quot;valid.asp&quot; method=&quot;post&quot; name=&quot;formu&quot;>
<table border=0 bordercolor=#000000>
<tr>
<td width=111>Login:</td>
<td><input type=&quot;text&quot; name=&quot;login&quot; size=10 maxlength=10></td>
</tr>
<tr>
<td width=111 height=24>Mot de passe:</td>
<td height=24><input type=&quot;password&quot; name=&quot;password&quot; size=10 maxlength=10>
</td>
</tr>
</table>
<input type=&quot;button&quot; value=&quot;ENTRER&quot; onclick=&quot;espacevide()&quot;>
<input type=&quot;reset&quot; value=&quot;ANNULER&quot;>

</form>

</body>
</html>
 
I have run this code and it works on my machine. You have to move the javascript to the <head> portion of the file, hope this works...

<Head>
<script language=&quot;JavaScript&quot;>

function espacevide(){
if (document.formu.login.value == &quot;&quot;)
{
alert(&quot;Vous devez inscrire votre login s.v.p.&quot;)
document.formu.login.focus();
return false;
}
document.formu.submit();
}
</script>
</Head>
<Body>
<form action=&quot;valid.asp&quot; method=&quot;post&quot; name=&quot;formu&quot;>
<table border=0 bordercolor=#000000>
<tr>
<td width=111>
Login:
</td>
<td>
<input type=&quot;text&quot; name=&quot;login&quot; size=10 maxlength=10>
</td>
</tr>
<tr>
<td width=111 height=24>Mot de passe:</td>
<td height=24%>
<input type=&quot;password&quot; name=&quot;password&quot; size=10 maxlength=10>
</td>
</tr>
</table>
<input type=&quot;button&quot; value=&quot;ENTRER&quot; onclick=&quot;javascript:espacevide();&quot;>
<input type=&quot;reset&quot; value=&quot;ANNULER&quot;>

</form>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top