Ok, this is probably going to sound pretty stupid...so please bear in mind that I'm completely new to php programming. Interested in the buzz about php I've recently downloaded the newest version 5.2.5 as well as MySQL server 5.0 and will be hosting web apps on Apache 2.2. I wrote a very simple program to get a feel for the syntax of php/MySQL programming...
[php]
Test.php - user-entered name and username
<html>
<form action="Insert. php5" method="post">
<table width=50% align="Center">
<tr>
<td width=50%>Enter your name:</td>
<td width=50%><inpu t type="text" name="name" /></td>
</tr>
<tr>
<td>Enter your UserName:</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" /></td>
</tr>
</table>
</form>
</html>
Insert.php5 - php page that appends users input into MySQL table:
<?php
$dbhost = 'localhost:3306 ';
$dbuser = 'user';
$dbpass = 'Password';
$conn = mysql_connect($ dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$Currentdb = mysql_select_db ("test", $conn);
$FName = $_POST['name'];
$UName = $_POST['username'];
$sql="INSERT INTO Users (Name, UserName) VALUES ('".$FName."' , '".$UName."' )";
$result = mysql_query($sq l, $conn) or die('Query failed: ' . mysql_error());
mysql_close($co nn);
?>[/php]This works all fine and dandy when executed through a trial edition of NuSphere but when i simply open my webbrowser to the testpage and enter a name and username it does not execute the php, instead it displays the code as though it's a text file. Is there some sort of packaging I need to include within the php page or framework needed to execute this code for regular deployment? Thanks in advance.
Jason
[php]
Test.php - user-entered name and username
<html>
<form action="Insert. php5" method="post">
<table width=50% align="Center">
<tr>
<td width=50%>Enter your name:</td>
<td width=50%><inpu t type="text" name="name" /></td>
</tr>
<tr>
<td>Enter your UserName:</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" /></td>
</tr>
</table>
</form>
</html>
Insert.php5 - php page that appends users input into MySQL table:
<?php
$dbhost = 'localhost:3306 ';
$dbuser = 'user';
$dbpass = 'Password';
$conn = mysql_connect($ dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$Currentdb = mysql_select_db ("test", $conn);
$FName = $_POST['name'];
$UName = $_POST['username'];
$sql="INSERT INTO Users (Name, UserName) VALUES ('".$FName."' , '".$UName."' )";
$result = mysql_query($sq l, $conn) or die('Query failed: ' . mysql_error());
mysql_close($co nn);
?>[/php]This works all fine and dandy when executed through a trial edition of NuSphere but when i simply open my webbrowser to the testpage and enter a name and username it does not execute the php, instead it displays the code as though it's a text file. Is there some sort of packaging I need to include within the php page or framework needed to execute this code for regular deployment? Thanks in advance.
Jason
Comment