Jump to content

my problem with jquery and oop php ? is there anyone ?


Recommended Posts

i have three page code in the following :

 

[/size][/font][/color]
<?php 
require_once('includes/funcs.class.php');
$objectUser = new func("localhost","root","","mesaeed");
if(isset($_POST['username']))
{
$objectUser->existUsername($_POST['username']); 
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="js/jquery-1.9.0.min.js" type="text/javascript"></script>
<script src="js/juser.js" type="text/javascript"></script>
<link rel="stylesheet" href="style.css" />
</head>

<body>
<div class="divclass">
<form action="index.php" method="post" id="login">
Username : <input type="text" name="username" id="username" /><br /><br />
Password : <input type="text" name="password" id="password" /><br /><br />
<input type="submit" value="login" id="submitlogin" /><br /><br />
</form>
</div>
</body>
</html>
[color=#000000][font=Tahoma, Verdana, Arial][size=3]

 

funcs.class.php :

 

[/size][/font][/color]
<?php
require_once('connect.class.php');
class func extends connect
{
protected $_dbusername;
protected $_dbemail;
protected $_dbpassword;
//User ..... Functions .....
function existUsername($dbusername)
{
$this->_dbusername = $dbusername;
global $dbtable,$dbsql,$dbquery;
$dbtable = "users";
$dbsql = "SELECT * FROM ".$dbtable." WHERE username = ?";
$dbquery = $this->_connect->prepare($dbsql);
$dbquery->bind_param("s", $this->_dbusername);
$dbquery->execute();
$dbquery->store_result();
if($dbquery->num_rows == 1)
{
echo "1";
}
else
{
echo "0";
}
$dbquery->close();
}
?>
[color=#000000][font=Tahoma, Verdana, Arial][size=3]

 

jquery.js :

 

 

// Javascript Document
$(document).ready(function(e) {
$("input#username").change(function(e) {
 var username = $("input#username").val()
 $.ajax({
  type: "POST",
  url: "index.php",
  data: {username: username},
  success: function(msg){
   if(msg == "1")
   {
    alert("Ok . ");
   }
   else
   {
    alert("No . ");
   }
   }
  });
   });
});[/size][/font][/color]
[color=#000000][font=Tahoma, Verdana, Arial][size=3]

 

but it doesnt work !!!!!

the orginal code enclosed .

meSaeed.zip

Edited by redhat2

Not only is it not object oriented its illogical. It doesn't make sense: "class func extends connect"? What on earth is that meant to mean?

 

When creating inheritance hierarchies it should be logical and you should consider the question "Is class A a class B" E.g. Is a Car a Vehicle? "class Car extends Vehicle".

Edited by cpd
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.