Jump to content

help on PHP code to work on localhost.


EdwinKST

Recommended Posts

hello, i am new to PHP and mySQL and was wondering if i could get any sort of help from someone with php knowledge to teach me how to make my windows read a php code on my localhost laptop. what do i require? what do i do after and such?

 

i have installed php, apache server, SQLyog, and mySQL .

 

some previous help that i got is to put the code into the Apache/htdocs folder.

i have done that, and my internet browser (mozzila) is still unable to read my code.

 

for example, i have this as a test to see if it would work:

 

<?

 

phpinfo();

 

?>

 

but in my internet browser, all i see is the same written coding as stated above, which means it isnt reading the code?

i am in a complete state of no ideas about this problem... so my question is mainly,

 

"How/What to do to make a php code work on a localhost?" by any means necessary with details and other options included..

 

please help if someone is able to. thank you.

Link to comment
https://forums.phpfreaks.com/topic/151806-help-on-php-code-to-work-on-localhost/
Share on other sites

PFMaBiSmAd got a good point.

 

short php tags doesn't work quite well if it's not defined in php.ini if im correct and because of this, you'll smash your forehead on your keyboard wondering whats going on!

 

and btw, Wampserver seems to work well.

on an added note, i am using windows vista if that has any relation to any errors that im fustrated at right now.

 

to taqiutosensei : AddModule mod_php.c doesnt seem to be in the apache/httpd.conf file at all. any thoughts about that? or is something terribly wrong? i have tried the code u mentioned under a different file (test2.php) and it still just shows out the written code as it is in my internet browser. pls help.

 

to kenrbnsn : in my internet browser, i type out " http://localhost/test.php ", and i have put the files (in .php) that i needed to read in the apache/htdocs folder.

 

here is one example of a php file im working on, and before u check the code below, id like to mention that this code seems to work on another friends localhost laptop perfectly with just a simple login interface as its output but doesnt on mine:

 

<? session_start();

 

ob_start();

include("functions/db.php");

$getDB=ob_get_contents();

ob_end_clean;

 

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<link rel="stylesheet" type="text/css" href="css/general.css" />

<link rel="stylesheet" type="text/css" href="css/forms.css" />

 

 

</head>

 

<body>

 

<?

if ( (isset($_POST['c_email'])) && (isset($_POST['p_word'])) )

{

$sql="select * from c_user where c_email='" . $_POST['c_email'] . "' AND c_pword='" . $_POST['p_word'] . "'";

$result=mysql_query($sql);

while ($row=mysql_fetch_array($result))

{

$c_type=$row['c_type'];

}

 

if (empty($c_type))

{

$error="There was an error in your login information. Please try again.";

}

else if ($c_type=='S')

{

$_SESSION['c_email']=$_POST['c_email'];

$_SESSION['c_pword']=$_POST['p_word'];

ob_start();

header('Location: student/main.php');

ob_end_clean;

 

}

else if ($c_type=='T')

{

$_SESSION['c_email']=$_POST['c_email'];

$_SESSION['c_pword']=$_POST['p_word'];

ob_start();

header('Location: teacher/main.php');

ob_end_clean;

 

}

 

}

 

?>

<div id="wrapper">

<form action="login.php" method="post">

<table class="generic" id="login">

<tr><th colspan='2'><? echo $error; ?></th></tr>

<tr><td>E-mail:</td><td><input type='text' name='c_email' id='c_email' class='data_form'></td></tr>

<tr><td>Password:</td><td><input type='password' name='p_word' id='p_word' class='data_form'></td></tr>

<tr><th colspan='2'><button type="submit">login!</button></th></tr>

</table>

</form>

</div>

 

</body>

 

</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.