Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok dito

Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

pero madaming company is need tlga ng may alam sa mga programming application/tools, which is kasama na din ang dreamweaver,,..but, sang ayon pa rin ako syo..

yep, additional skills yung marunong sa mga ganyang programming applications, from what I see, those companies prefer people knowledgeable on those apps for the rapid prototyping phase of software development... mas madali kasi magdevelop / gumawa ng running sites using those apps, but then, you still need to have the core knowledge for site development, lalo na sa debugging / customization...
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Yes eclipse is good too as editor. I'm using it. Then pag debugging stage ka na gamit ka ng addons ng firefox like firePHP and firebug. It can help sa pag check ng mga values and errors na ma encounter sa testing
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

mga master ano po kaya kulang ko sa code na ito ayaw kasi mag update po nag loop back lng sa inventory_list.php walang nangyayare. salamat po!

here is the code:

<? ob_start(); ?>
<?php
session_start();
if(!isset($_SESSION["manager"])){
header("location:admin_login.php");
exit();

}

//be sure to check this manager SESSION value is in fact in the database
$managerID = preg_replace('#[^0-9]#i','',$_SESSION["id"]); //filter everything but numbers and letters
$manager = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["manager"]); //filter everything but numbers and letters
$password = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["password"]); //filter everything but numbers and letters
//Run mySQL query to be sure that this person is an admin and their password session var equals the database information
//connect to mySQL database
include "../storescripts/connect_to_mysql.php";
$sql = mysql_query("SELECT* FROM admin WHERE id='$managerID'AND username='$manager' AND password='$password' LIMIT 1"); //query the person
//.......MAKE SURE PERSON EXISTS IN THE DATABASE............
$existCount = mysql_num_rows($sql); //count the rows nums
if($existCount ==1){//evaluate the count
echo "Your login session data is not on record in the database.";
exit();
}
?>
<?php
//Script Error Reporting
error_reporting(E_ALL);
ini_set('diplay_errors','1');
?>

<?php
//Parse the form data and add inventory item to the system
if(isset($_POST['product_name'])){

$pid = mysql_real_escape_string($_POST['thisID']);
$product_name = mysql_real_escape_string($_POST['product_name']);
$price = mysql_real_escape_string($_POST['price']);
$category = mysql_real_escape_string($_POST['category']);
$subcategory = mysql_real_escape_string($_POST['subcategory']);
$details = mysql_real_escape_string($_POST['details']);
//See if that product name is an identical match to another product in the system
$sql = mysql_query("UPDATE products SET product_name='$product_name', price='$price', details='$details', category='$category', subcategory='$subcategory' WHERE id='$pid'");
$sql = mysql_query($sql) or die("<br>Insertion failed");
if($_FILES['fileField']['tmp_name'] !=""){
//Place image in Folder
$newname = "$pid.jpg";
move_uploaded_file($_FILES['fileField']['tmp_name'], "../inventory_images/$newname");
}
header("location:inventory_list.php");
exit();
}
?>
<?php
//gather this product's full information for inserting automatically into the edit form below on page
if (isset($_GET['pid'])){
$targetID = $_GET['pid'];
$sql = mysql_query("SELECT* FROM products WHERE id='$targetID' LIMIT 1");
$productCount = mysql_num_rows($sql); //count the output amount
if ($productCount > 0){
while($row = mysql_fetch_array($sql)){

$product_name = $row["product_name"];
$price = $row["price"];
$category = $row["category"];
$subcategory = $row["subcategory"];
$details = $row["details"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));

}
} else{
echo "sorry that crap dont exist.";
exit();
}
}

?>
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Which part did you assign these sessions

$_SESSION["id"]
$_SESSION["manager"]
$_SESSION["password"]

in these following lines
Code:
$managerID = preg_replace('#[^0-9]#i','',$_SESSION["id"]); //filter everything but numbers and letters
$manager = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["manager"]); //filter everything but numbers and letters
$password = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["password"]); //filter everything but numbers and letters
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

//See if that product name is an identical match to another product in the system
$sql = mysql_query("UPDATE products SET product_name='$product_name', price='$price', details='$details', category='$category', subcategory='$subcategory' WHERE id='$pid'");
$sql = mysql_query($sql) or die("<br>Insertion failed");

?>

Sir kindly check this, yung unang value ng $sql mo ay result ng query mo then ginamit mo na parameter sa second statement. pwedeng di mo na gamitin yung statement na to

$sql = mysql_query($sql) or die("<br>Insertion failed");

or if we rewrite your code

$sql = "UPDATE products SET product_name='$product_name', price='$price', details='$details', category='$category', subcategory='$subcategory' WHERE id='$pid'";
$result = mysql_query($sql) or die("<br>Insertion failed");

it is also a good practice to set a die statement like this
$result=mysql_query($query) or die("Error in Line ".__LINE__.":\n$query".__FILE__."\n". mysql_error());
para alam mo kung anong file, line at sql error.
 
Last edited:
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Sir kindly check this, yung unang value ng $sql mo ay result ng query mo then ginamit mo na parameter sa second statement. pwedeng di mo na gamitin yung statement na to

$sql = mysql_query($sql) or die("<br>Insertion failed");

or if we rewrite your code

$sql = "UPDATE products SET product_name='$product_name', price='$price', details='$details', category='$category', subcategory='$subcategory' WHERE id='$pid'";
$result = mysql_query($sql) or die("<br>Insertion failed");

it is also a good practice to set a die statement like this
$result=mysql_query($query) or die("Error in Line ".__LINE__.":\n$query".__FILE__."\n". mysql_error());
para alam mo kung anong file, line at sql error.

This is the feature that I like with PHP. A single variable can handle all types. Hahaha I used to have this to optimize my codes. Using less variable means less memory usage. :)

And I don't do this.
$sql = "SQL STATEMENT IN HERE";
$sql = mysql_query($sql);

Instead I do

$sql = mysql_query("SQL STATEMENT IN HERE");
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Sir wala kasi akong background sa mysql database. Paturo naman sir.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

hakuna_matata_hm
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2
Which part did you assign these sessions

$_SESSION["id"]
$_SESSION["manager"]
$_SESSION["password"]

in these following lines
Code:
$managerID = preg_replace('#[^0-9]#i','',$_SESSION["id"]); //filter everything but numbers and letters
$manager = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["manager"]); //filter everything but numbers and letters
$password = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["password"]); //filter everything but numbers and letters
Yesterday 16:50


Sir what do you mean part?
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

then here po ung update button

<td><label>
<input name="thisID" type="hidden" value="<?php echo $targerID; ?>" />
<input type="submit" name="button" id="button" value="update"/>
</label></td>

ayaw parin po eh.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Sir what do you mean part?

I mean saan mo ina.ssignan ng value ang mga $_SESSIONs na yon?
I don't see this lines kasi

$_SESSION["id"] = $some_variable_in_here;
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

pasensya na po bago lang sa php.

sa inventory_list.php


then e2 ung code ng admin_login.php

<?php

session_start();
if(isset($_SESSION["manager"])){
header("location:index.php");
exit();
}
?>
<?php
//parse the log in form if the user has filled it out and pressed"login"
if(isset($_POST["username"])&& isset($_POST["password"])){

$manager = preg_replace('#[^A-Za-z0-9]#i','',$_POST["username"]); //filter everything but numbers and letters
$password = preg_replace('#[^A-Za-z0-9]#i','',$_POST["password"]); //filter everything but numbers and letters
//connect to the mySQL database
include "../storescripts/connect_to_mysql.php";
$sql = mysql_query("SELECT id FROM admin WHERE username='$manager' AND password='$password' LIMIT 1"); //query the person
// .....MAKE SURE PERSON EXISTS IN DATABASE........
$existCount = mysql_num_rows($sql); //count the rows nums
if($existCount ==0){//evaluate the count
while($rows = mysql_fetch_array($sql)){
$id = $row["id"];
}
$_SESSION["id"]= $id;
$_SESSION["manager"]= $manager;
$_SESSION["password"]= $password;
header("location:index.php");
exit();
}else {
echo 'That information is incorrect, try again <a href="index.php">Click here</a>';
exit();
}
}
?>
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

then sir here po ung code ng inventory_list.php ko


<? ob_start();?>
<?php

session_start();
if(!isset($_SESSION["manager"])){
header("location:admin_login.php");
exit();

}

//be sure to check this manager SESSION value is in fact in the database
$managerID = preg_replace('#[^0-9]#i','',$_SESSION["id"]); //filter everything but numbers and letters
$manager = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["manager"]); //filter everything but numbers and letters
$password = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["password"]); //filter everything but numbers and letters
//Run mySQL query to be sure that this person is an admin and their password session var equals the database information
//connect to mySQL database
include "../storescripts/connect_to_mysql.php";
$sql = mysql_query("SELECT* FROM admin WHERE id='$managerID'AND username='$manager' AND password='$password' LIMIT 1"); //query the person
//.......MAKE SURE PERSON EXISTS IN THE DATABASE............
$existCount = mysql_num_rows($sql); //count the rows nums
if($existCount ==0){//evaluate the count
echo "Your login session data is not on record in the database.";
exit();
}


?>
<?php
//Script Error Reporting
error_reporting(E_ALL);
ini_set('diplay_errors','1');
?>
<?php
//delete item question to admin
if (isset($_GET['deleteid'])){
echo 'Do you want to delete product with ID of' .$_GET['deleteid']. '?<a href="inventory_list.php?yesdelete='.$_GET['deleteid'].'">Yes</a> | <a href="inventory_list.php">No</a>';
exit();
}
if (isset($_GET['yesdelete'])){
//remove item from system and delete its picture
//delete from database
$id_to_delete = $_GET['yesdelete'];
$sql = mysql_query("DELETE FROM products WHERE id='$id_to_delete' LIMIT 1") or die(mysql_error());
//unlink the image from server
//remove the pic ..........................
$pictodelete = ("../inventory_images/$id_to_delete.jpg");
if (file_exists($pictodelete)){
unlink($pictodelete);
}
header("location:inventory_list.php");
exit();
}
?>
<?php
//Parse the form data and add inventory item to the system
if(isset($_POST['product_name'])){

$product_name = mysql_real_escape_string($_POST['product_name']);
$price = mysql_real_escape_string($_POST['price']);
$details = mysql_real_escape_string($_POST['details']);
$category = mysql_real_escape_string($_POST['category']);
$subcategory = mysql_real_escape_string($_POST['subcategory']);
//See if that product name is an identical match to another product in the system
$sql = mysql_query("SELECT id FROM products WHERE product_name='$product_name' LIMIT 1");
$productMatch = mysql_num_rows($sql);//count the output amount
if($productMatch > 0){
echo 'Sorry you tried to place a duplicate "Product Name" into the system, <a href="inventory_list.php">click here</a>';
exit();
}
//Add this product into the database now
$sql = mysql_query("INSERT INTO products (product_name, price, details, category, subcategory, date_added)
VALUES('$product_name','$price','$details','$category','$subcategory', now())")or die(mysql_error());
$pid = mysql_insert_id();
//Place image in Folder
$newname = "$pid.jpg";
move_uploaded_file($_FILES['fileField']['tmp_name'], "../inventory_images/$newname");
header("location:inventory_list.php");
exit();
}
?>
<?php
//this block grabls the whole list for viewing
$product_list="";
$sql = mysql_query("SELECT* FROM products ORDER BY date_added DESC");
$productCount = mysql_num_rows($sql); //count the output amount
if ($productCount > 0){
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$product_name = $row["product_name"];
$price = $row["price"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$product_list .= "Product ID: $id - <strong>$product_name</strong> - $$price - $date_added       <a href='inventory_edit.php?pid=$id'>edit</a> • <a href='inventory_list.php?deleteid=$id'>delete</a><br />";
}
} else{
$product_list = "you have no products listed in your store yet";
}

?>
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Ang point ko dun sa last post ko hindi yung variable. Kindly look this and analyze.

$sql = mysql_query("UPDATE products SET product_name='$product_name', price='$price', details='$details', category='$category', subcategory='$subcategory' WHERE id='$pid'");
$sql = mysql_query($sql) or die("<br>Insertion failed");

the result of the query is assigned to the paramereter of mysql_query.

I respect your technique in programming sir
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

sir jeremaya try ko ung sinabi nyo kaso ayaw pa din po
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Ang point ko dun sa last post ko hindi yung variable. Kindly look this and analyze.

$sql = mysql_query("UPDATE products SET product_name='$product_name', price='$price', details='$details', category='$category', subcategory='$subcategory' WHERE id='$pid'");
$sql = mysql_query($sql) or die("<br>Insertion failed");

the result of the query is assigned to the paramereter of mysql_query.

I respect your technique in programming sir


I see, I haven't seen the mysql_query

Hahaha. Tanga... Yes it will always Insertion failed. Bakit? Di query statement yong nilagay dito mysql_query($sql); kundi resource cya.

Parang may kulang dun na INSERT statement between the $sql assignment statements.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

sir saang insert po?
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

Basahin po ninyo yong comment ko. And understand it. That's so clear ano dapat mangyayari dun.
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

akomay tanong ..plano ko na gumawang grading system na php based ... meron bang pwedeng makuhanan ng example kasi nag hahanap wala ako makita
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

sino po ba may kayang gumawa dito ng Voucher Panel para sa vpn?
 
Re: Mga Tanong tungkol sa PHP, CSS, jquery, HTML at MySQL pasok D2

akomay tanong ..plano ko na gumawang grading system na php based ... meron bang pwedeng makuhanan ng example kasi nag hahanap wala ako makita

mahirap tlga maghanap ng ganyang system,the best way is simulan mo na ng paunti unti,then if may na encounter kang problem sa ginagawa mong codes,,feel free to ask here...:)
 
Back
Top Bottom