473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Why does php page output full source code when run in browser?

i have create a register page in php and connect to a database using phpmyadmin in my personal pc and its works perfectly but when i transfer the same page into another pc and connect the it to the same database it does not work...the page open and all the php code appears above the table form
below is the php code


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo "<h1>register</h1>";
  3. $submit=$_POST['submit'];
  4.  
  5.  
  6. $firstname=strip_tags($_POST['firstname']);
  7. $lastname=strip_tags($_POST['lastName']);
  8. $email=strip_tags($_POST['email']);
  9. $telephone=strip_tags($_POST['telephone']);
  10. $address=strip_tags($_POST['address']);
  11. $username=strip_tags($_POST['username']);
  12. $password=(strip_tags($_POST['password']));
  13. $repeatpassword=(strip_tags($_POST['repeatpassword']));
  14.  
  15. if($submit)
  16. {
  17. //open database
  18. $connect=mysql_connect("localhost","root","");
  19. mysql_select_db("register");
  20. $namecheck=mysql_query("SELECT username FROM users WHERE username='$username'");
  21. $count=mysql_num_rows($namecheck);
  22. if ($count!=0)
  23. {
  24. die("username already taken");
  25. }
  26.  
  27.  
  28. //CHECK FOR EXISTANCE
  29. if ($firstname&&$lastname&&$email&&$telephone&&$address&&$username&&$password&&$repeatpassword)
  30. {
  31.  
  32. if ($password==$repeatpassword)
  33. {
  34. //chek char length of username and names
  35. if (strlen($firstname)>20||strlen($lastname)>20||strlen($username)>20)
  36. {
  37. echo "Max Limit for first name, last name and username are 20 characters";
  38. }
  39. else
  40. {
  41. //check password length
  42. if (strlen($password)>25||strlen($password)<6)
  43. {
  44. echo "Password must be between 6 and 25 characters";
  45. }
  46. else
  47. {
  48. //register the user
  49. $queryreg=mysql_query("
  50. INSERT INTO users VALUES ('','$firstname','$lastname','$email','$telephone','$address','$username','$password')
  51. ");
  52. die ("you have been registered");
  53. }
  54. }
  55. }
  56. else
  57. echo "your passsword do not match";
  58. }
  59. else
  60. echo "please fills in <b>all</b> fields";
  61. }
  62.  
  63.  
  64. ?>
  65. <html>
  66. <p align="left">
  67. <form action='register.php' method='POST'>
  68. <table>
  69. <tr>
  70. <td>
  71. <b>First Name:</b>
  72. </td>
  73. <td>
  74. <input type='text' name='firstname'>
  75. </td>
  76. </tr>
  77. <tr>
  78. <td height="36">
  79. <b>Last Name:</b>
  80. </td>
  81. <td>
  82. <input type='text' name='lastName'>
  83. </td>
  84. </tr>
  85. <tr>
  86. <td height="36">
  87. <b>Email:</b>
  88. </td>
  89. <td>
  90. <input type='text' name='email'>
  91. </td>
  92. </tr>
  93. <tr>
  94. <td height="36">
  95. <b>Telephone::</b>
  96. </td>
  97. <td>
  98. <input type='text' name='telephone'>
  99. </td>
  100. </tr>
  101. <tr>
  102. <td height="36">
  103. <b>Address:</b>
  104. </td>
  105. <td>
  106. <input type='text' name='address'>
  107. </td>
  108. </tr>
  109. <tr>
  110. <td height="36">
  111. <b>Username:</b>
  112. </td>
  113. <td>
  114. <input type='text' name='username'>
  115. </td>
  116. </tr>
  117. <tr>
  118. <td height="36">
  119. <b>Password:</b>
  120. </td>
  121. <td>
  122. <input type='text' name='password'>
  123. </td>
  124. </tr>
  125. </tr>
  126. <tr>
  127. <td height="36">
  128. <b>Repeat Passowrd:</b>
  129. </td>
  130. <td>
  131. <input type='text' name='repeatpassword'>
  132. </td>
  133. </tr>
  134. <tr>
  135. <td>
  136. <input type='submit' name='submit' value='Register'>
  137. </td>
  138. </tr>
  139. </table>
  140. </form>
  141. </p>
  142. </html>
  143.  
when i open a the register page the following codes appears above the tables

Expand|Select|Wrap|Line Numbers
  1. register"; $submit=$_POST['submit']; $firstname=strip_tags($_POST['firstname']); $lastname=strip_tags($_POST['lastName']); $email=strip_tags($_POST['email']); $telephone=strip_tags($_POST['telephone']); $address=strip_tags($_POST['address']); $username=strip_tags($_POST['username']); $password=(strip_tags($_POST['password'])); $repeatpassword=(strip_tags($_POST['repeatpassword'])); if($submit) { //open database $connect=mysql_connect("localhost","root","root"); mysql_select_db("register"); $namecheck=mysql_query("SELECT username FROM users WHERE username='$username'"); $count=mysql_num_rows($namecheck); if ($count!=0) { die("username already taken"); } //CHECK FOR EXISTANCE if ($firstname&&$lastname&&$email&&$telephone&&$address&&$username&&$password&&$repeatpassword) { if ($password==$repeatpassword) { //chek char length of username and names if (strlen($firstname)>20||strlen($lastname)>20||strlen($username)>20) { echo "Max Limit for first name, last name and username are 20 characters"; } else { //check password length if (strlen($password)>25||strlen($password)<6) { echo "Passowrd must be between 6 and 25 characters"; } else { //register the user $queryreg=mysql_query(" INSERT INTO users VALUES ('','$firstname','$lastname','$email','$telephone','$address','$username','$password') "); die ("you have been registered"); } } } else echo "your passsword do not match"; } else echo "please fills in all fields"; } ?>



can someone help me
Feb 2 '11 #1
4 2389
Niheel
2,460 Expert Mod 2GB
This seems like it might be caused from there being no webserver on the other PC. Either no webserver or the webserver installation does not support PHP.

That's the most common cause of full code display when executing a php file.
Feb 2 '11 #2
in the pc WAMP5 is install and works properly...infact i have test the page in many windows pc and the problem persist except in a macbook
Feb 2 '11 #3
Markus
6,050 Expert 4TB
The browser should be of no significance here.

Are you trying to access a webserver on computer 1 (a Windows machine) from a different computer (a Macbook)?
Feb 2 '11 #4
i have found the solution to the problem, in the pc, IIS was install to disable it i had wrongly reconfigure certain setting...now its working properly.. thnks anyways markus and niheel
Feb 2 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Savas Ates | last post by:
can i send my page title to another page.... like this response.redirect "xx.asp?title"&mytitle mytitle= what can bee... i dont want to write manually my title any method to learn title in...
6
by: bissatch | last post by:
Hi, I have been tryin to run free dhtml code from a web page. The web page is: http://dynamicdrive.com/dynamicindex14/pixelate.htm When I load the page above it opens as normal and the...
7
by: moondaddy | last post by:
I'm building a page in vb.net with several user controls on it. I'm using user controls instead of a frames page since I've seen this recommended many times in this user group. I want just one of...
7
by: morrisdn13 | last post by:
I have encountered a very strange problem that makes it look like the page is not recreated in entirety after a postback when I turn on smartnavigation. If I click on a server control, the page...
2
by: Dave | last post by:
I'm fairly new to this ASPX/OLEDB stuff. I have an OleDbDataReader in one ..aspx page. I do a Server.Transfer to another page. Is it possible to make it so that the data in the OleDbDataReader is...
1
by: Don | last post by:
I have a user control that uses Atlas to call a web service. I drop this control on a page in the root directory and it works with no problem. I then add the control to another control, which is...
1
by: Nick Zdunic | last post by:
In 1.1 it was possible to refer to a web page class from another class I've just started in v2.0 and found that this code sn't working The web page class: Partial Class _Default Inherits...
2
by: Bren | last post by:
Hi All I am just in the process of taking the leap into .net 2 and vs 2005 and a I have come across a bit of a problem. I have created an Intranet app and have the following folder structure:-...
1
by: thejackofall | last post by:
I can use a good help here with what looks like a simple problem. I have a control called Header.ascx in /Control/System directory, where / is my web application directory. The header is used...
3
by: ArunDhaJ | last post by:
Hi All, I've a grid with say 100 records with pagination of 10 records per page. Given a record, how can I identify which page does this record is available? As the grid size can be much larger...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.