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
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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.