BTC USD 86,658.1 Gold USD 4,345.18
Time now: Jun 1, 12:00 AM

problem with php

ruzana

Active Member
Messages
2,307
Joined
Jan 3, 2011
Messages
2,307
Reaction score
1
Points
25
assalamualaikum semua..sape kat sini tahu pasal php??sy ade masalah sikit.saya ade buat satu sistem ni.sistem ni memerlukan pengguna untuk login.dan bila login,sistem akan cek sama ada username dan password y diberikan itu betul atau pun tidak.so masalah sekarang,bila sy tekan submit je,mesti klua balik semua coding2 php tu,,kenape ye???~X(~X(~X(~X(

ni error lepas da tukar y level tu
 

Attachments

  • 75.7 KB Views: 37
Last edited:
form da ok,,cume bile tekan submit je,klua coding php,,coding y tok semak kata laluan tu
 
cuba tt tepek jer coding tue kat cnie...nk download yg rmi mls nk tlg tue.....hehehehe.....
 
ok2,,,
abaikan coding tu,,
ni coding form


<?php

// Inialize session
//session_start();

// Check, if user is already login, then jump to secured page
//if (isset($_SESSION['username'])) {
//header('Location: prog/login berjaya.php');
//}

?>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-size: 36px;
font-weight: bold;
}
.style2 {
font-size: 24px;
font-weight: bold;
}
-->
</style>
</head>

<body bgcolor="#00CCFF">

<div align="center"><img src="img/banner.jpg" width="822" /></div>
<form id="form1" name="form1" method="post" action="prog/login berjaya.php">
<label></label>
<table width="596" border="1" align="center">
<tr>
<td width="586"><div align="center"><span class="style2">SISTEM ADUAN KEROSAKAN ICT</span></div></td>
</tr>
<tr>
<td><table width="347" border="3" align="center">
<tr>
<td width="178">KAD PENGENALAN</td>
<td width="9">:</td>
<td width="134"><input name="username" type="text" id="username" size="21" /></td>
</tr>
<tr>
<td>KATA LALUAN</td>
<td>:
<label></label></td>
<td><input name="password" type="password" id="password" size="21" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><div align="center">
<input type="submit" name="button" id="button" value="Hantar" />
<input type="reset" name="button2" id="button2" value="Reset" />
</div></td>
</tr>
</table>
<p align="center">
<label></label>
<label></label>
</p>
</form>

<p> </p>
</body>
</html>


ni coding semak kata laluan

<?php

$mysql_server = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "sistem_aduan_kerosakan_ict";

$conn = mysql_connect($mysql_server, $mysql_user, $mysql_password);

mysql_select_db($mysql_database, $conn);


// username and password sent from form
$myusername=$_POST['username'];
$mypassword=$_POST['password'];

// encrypt password
$encrypted_mypassword=md5($mypassword);

$sql="SELECT * FROM pengguna WHERE username='$myusername' and password='$encrypted_mypassword'";
$result=mysql_query($sql);


// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);


// If result matched $myusername and $mypassword, table row must be 1 row

if(mysql_num_rows($result) > 0){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_start();
$_SESSION['username'] = $myusername;
$_SESSION['password'] = $mypassword;
header("location:berjaya semak.php");
}
else {
echo "Username dan Kata Laluan salah";
}
?>

ni coding berjaya semak


<?
include("../connect db/connct.php");

//if(!session_is_registered(username)){
//header("location:pentadbir.php");
//}
//new from me

if(!isset($_SESSION['username'])){
header("location:../../index.php");
}
?>

<html>
<body>
Login Successful
</body>
</html>

<body>
</body>
</html>
 
sy gune windows

Pastu filename .html ke?

Ada 2 problem:
1. Unless buat setting betul php code tak boleh run dlm file .html file

2. Windows server tapi guna Apache ke atau IIS? Kalau IIS kena buat additional setting baru leh run code php. IIS biasanya utk run code asp natively by default.
 
Pastu filename .html ke?

Ada 2 problem:
1. Unless buat setting betul php code tak boleh run dlm file .html file

2. Windows server tapi guna Apache ke atau IIS? Kalau IIS kena buat additional setting baru leh run code php. IIS biasanya utk run code asp natively by default.

mule2 wat html..
now sume da tukr jadi php,,
gune apache,,
sbb sy gune xampp
 
Back
Top
Log in Register