can someone convert this jsp page to php please. :( <!DOCTYPE html PUBLIC \"-//W
ID: 3803220 • Letter: C
Question
can someone convert this jsp page to php please. :(
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script> function startCountdown() { window.setTimeout(alertSessionTimeout, (120 * 1000)); } function alertSessionTimeout() { alert("You're login session has been expired, LOGIN again to continue :) "); setTimeout('Redirect()', 500); } function Redirect() { window.location = "logout.jsp"; } </script> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>GAMESKART</title> <style type="text/css"> .right { text-align: right; } #form1 { text-align: center; } .normal { text-align: left; font-weight: bold; font-family: Arial, Helvetica, sans-serif; } .unormal { font-family: Arial, Helvetica, sans-serif; } .center1 { text-align: center; } </style> </head> <body background="./images/bg-box.gif" > <center><img alt="Games Kart" src="./images/sitelogo.png"></center> <marquee><strong>*** NEW ARRIVALS *** | *** FEATURED GAMES *** | *** BESTSELLING GAMES *** | *** BUDGET GAMES ***</strong></marquee> <table width="100%" border="0"> <tr> <td width="20%"> <a href="home.jsp"><img src="images/videogames.jpg" width="251" height="88" alt="Logo" /></a> </td> <td width="80%" class="right"><font size="04"> 24X7 Customer Support -<a href="contact.jsp">Contact Us</a> | <a href="home.jsp">Home</a> | <a href="login.jsp">Login</a> | <a href="register.jsp">Register</a> <br><br> <form id="form1" name="form1" method="post" action="search.jsp"> <input name="searchString" type="text" id="searchString" /> <label> <input type="submit" name="submit" value="Search" /> </label> </font> </form> </td> </tr> </table> <hr /> <style type="text/css"> .right { text-align: right; } </style> </head> <body> <center> <strong>Register here</strong> <form action="registerUser.jsp" method="post" name="registerForm"> <table> <tr> <td>Profile Name</td> <td><input type="text" name="profileName"><b><font color="red">*</font></b></td> </tr> <tr> <td>Username</td> <td><input type="text" name="username"><b><font color="red">*</font></b></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password"><b><font color="red">*</font></b></td> </tr> <tr> <td>User Type</td> <td> <select name="userTypeId"> <option value="userTypeId">User Type</option> <option value="2">SELLER</option> <option value="3">CUSTOMER</option> </select> <b><font color="red">*</font></b> </td> </tr> <tr> <td>Phone Number</td> <td><input type="text" name="phoneNumber"></td> </tr> <tr> <td>Email ID</td> <td><input type="text" name="emailId"></td> </tr> <tr> <td>Date of Birth</td> <td><input type="text" name="dateOfBirth"></td> </tr> <tr> <td>Address</td> <td><textarea name="address"></textarea></td> </tr> <tr> <td align="center"><input type="submit" value="Register" /></td> <td align="center"><input type="reset" value="Clear"></td> </tr> </table> <br /> <b><font color="red">*</font></b> Fields are mandatory. </form> <br> <hr> Already Registered!! To Login <a href="login.jsp">Click Here</a> <hr> </center> <script lang="javascript" type="text/javascript"> function validateUserDetails() { var profileName = document.forms["registerForm"]["profileName"].value; if(profileName = undefined || profileName == "" || profileName == '') { alert("Please enter profile name."); return false; } var username = document.forms["registerForm"]["username"].value; if(username = undefined || username == "" || username == '') { alert("Please enter username."); return false; } var password = document.forms["registerForm"]["password"].value; if(password = undefined || password == "" || password == '') { alert("Please enter password."); return false; } var userTypeId = document.forms["registerForm"]["userTypeId"].value; if(userTypeId = undefined || profileName == "userTypeId" || userTypeId == 'userTypeId') { alert("Please enter user type."); return false; } } </script> </body> </html>Explanation / Answer
I looked at you code of html page, and i can see that you have all the code as the static code, so you don't need to change anything in your code, except the pages to which you are forwarding the request to. Like, you have login menu defined as login.jsp now, later for PHP it will become something like login.php; hence you need to change all the static links which point to some page in jsp system currently. Besides that, there is no dynamic jsp element(Dynamic element means, any element which gets its value currently from servlet or bean, that need to be changed in php system through acceess variables), so you need no other change.
I have kept the sample below:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script>
function startCountdown() {
window.setTimeout(alertSessionTimeout, (120 * 1000));
}
function alertSessionTimeout() {
alert("You're login session has been expired, LOGIN again to continue :) ");
setTimeout('Redirect()', 500);
}
function Redirect() {
window.location = "logout.jsp";
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>GAMESKART
</title>
<style type="text/css">
.right {
text-align: right;
}
#form1 {
text-align: center;
}
.normal {
text-align: left;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
}
.unormal {
font-family: Arial, Helvetica, sans-serif;
}
.center1 {
text-align: center;
}
.right {
text-align: right;
}
</style>
</head>
<body background="./images/bg-box.gif" >
<center>
<img alt="Games Kart" src="./images/sitelogo.png">
</center>
<marquee>
<strong>*** NEW ARRIVALS *** | *** FEATURED GAMES *** | *** BESTSELLING GAMES *** | *** BUDGET GAMES ***
</strong>
</marquee>
<table width="100%" border="0">
<tr>
<td width="20%">
<a href="home.php">
<img src="images/videogames.jpg" width="251" height="88" alt="Logo" />
</a>
</td>
<td width="80%" class="right">
<font size="04">
24X7 Customer Support -
<a href="contact.php">Contact Us
</a> |
<a href="home.php">Home
</a> |
<a href="login.php">Login
</a> |
<a href="register.php">Register
</a>
<br>
<br>
<form id="form1" name="form1" method="post" action="search.php">
<input name="searchString" type="text" id="searchString" />
<label>
<input type="submit" name="submit" value="Search" />
</label>
</font>
</form>
</td>
</tr>
</table>
<hr />
<center>
<strong>Register here
</strong>
<form action="registerUser.php" method="post" name="registerForm">
<table>
<tr>
<td>Profile Name
</td>
<td>
<input type="text" name="profileName">
<b>
<font
color="red">*
</font>
</b>
</td>
</tr>
<tr>
<td>Username
</td>
<td>
<input type="text" name="username">
<b>
<font
color="red">*
</font>
</b>
</td>
</tr>
<tr>
<td>Password
</td>
<td>
<input type="password" name="password">
<b>
<font
color="red">*
</font>
</b>
</td>
</tr>
<tr>
<td>User Type
</td>
<td>
<select name="userTypeId">
<option value="userTypeId">User Type
</option>
<option value="2">SELLER
</option>
<option value="3">CUSTOMER
</option>
</select>
<b>
<font color="red">*
</font>
</b>
</td>
</tr>
<tr>
<td>Phone Number
</td>
<td>
<input type="text" name="phoneNumber">
</td>
</tr>
<tr>
<td>Email ID
</td>
<td>
<input type="text" name="emailId">
</td>
</tr>
<tr>
<td>Date of Birth
</td>
<td>
<input type="text" name="dateOfBirth">
</td>
</tr>
<tr>
<td>Address
</td>
<td>
<textarea name="address">
</textarea>
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="Register" />
</td>
<td align="center">
<input type="reset" value="Clear">
</td>
</tr>
</table>
<br />
<b>
<font color="red">*
</font>
</b> Fields are mandatory.
</form>
<br>
<hr>
Already Registered!! To Login
<a href="login.php">Click Here
</a>
<hr>
</center>
<script lang="javascript" type="text/javascript">
function validateUserDetails() {
var profileName = document.forms["registerForm"]["profileName"].value;
if(profileName = undefined || profileName == "" || profileName == '') {
alert("Please enter profile name.");
return false;
}
var username = document.forms["registerForm"]["username"].value;
if(username = undefined || username == "" || username == '') {
alert("Please enter username.");
return false;
}
var password = document.forms["registerForm"]["password"].value;
if(password = undefined || password == "" || password == '') {
alert("Please enter password.");
return false;
}
var userTypeId = document.forms["registerForm"]["userTypeId"].value;
if(userTypeId = undefined || profileName == "userTypeId" || userTypeId == 'userTypeId') {
alert("Please enter user type.");
return false;
}
}
</script>
</body>
</html>
Its pretty plain HTML, CSS and JS. These are basic languages and exist both in JSP and PHP as HTML,JS,CSS are cliennt side languages; while JSP and PHP are server side languages. Server side laguages perform the work and convert the page to language which client can understand. Here your page itself is in client side laguage only, so no processing is required. Just put correct navigation links.. thats it.
Thanks, hope i am clear !!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.