Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Do Javascript and PHP have the same abilities?
New Posts  All Forums:Forum Nav:

Do Javascript and PHP have the same abilities?

post #1 of 9
Thread Starter 
Is Javascript and PHP both worth learning? Also, what should I learn first?

Thanks...
post #2 of 9
I am about to buy books on both of these subjects
umm as far as i know you use javascript to make your website more interactive,
and PhP is used for databases i think
I have been recommended (by my teacher) JQueary in action second edition and Head first PhP and MySQL
hope that helps
post #3 of 9
Not really... no PHP is basically the middleman between an HTML page and an SQL Database. You generate queries through it. Here is a basic example of a login call from a webpage I designed (very basic)

[php]function clean($str)
{
$str = @trim($str);
if(get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}

//Sanitize the POST values
$username = clean($_POST);
$password = clean($_POST);

//Input Validations
if($username == '') {
$errmsg_arr[] = 'Username missing';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}


if($errflag)
{
$_SESSION = $errmsg_arr;
session_write_close();
header("location: loginretry.php");
exit();
}

//If there is an error, send the user to the loginretry.php page

$salt= '_$_%123';

//This is part of the password encryption when the user registers


$qry="SELECT * FROM users WHERE username='$username' AND password='".md5($_POST.$salt)."'";
$result=mysql_query($qry);
//Posts values to the database and encrypts the password

//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) == 1) {
//If login was Successful
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION = $member;
$_SESSION = $member;
$_SESSION = $member;
session_write_close();
header("location: index.php");
exit();
}else {
//If login failed take to login retry page
header("location: loginretry.php");
exit();
}
}else {
die("Query failed");
}
?>
[/php]
post #4 of 9
Thread Starter 
Thanks...I have head first PHP & MySQL and today I just picked up Javascript & Ajax from the Visual Quickstart Guide seventh edition. So I was just wondering what the real differences are
post #5 of 9
It's kinda like comparing apples to oranges. Javascript was created to aid HTML. PHP was created as a scripting language.

PHP is server side. Javascript/jquery is client side.

Up top, PHP does deal with SQL Databases. However it's abilities far out number just Databases
    
CPUMotherboardGraphicsGraphics
i7 2600k Gigabyte P67-UD4-B3 GTX 580 GTX 580 
RAMHard DriveOSMonitor
Who cares? Intel SSD  Windows 7 Dell u3011 
MonitorPowerCaseMouse
Dell u3011 Seasonic x1200 800D G700 
AudioAudio
Xonar STX Beyerdynamic DT 990 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
i7 2600k Gigabyte P67-UD4-B3 GTX 580 GTX 580 
RAMHard DriveOSMonitor
Who cares? Intel SSD  Windows 7 Dell u3011 
MonitorPowerCaseMouse
Dell u3011 Seasonic x1200 800D G700 
AudioAudio
Xonar STX Beyerdynamic DT 990 
  hide details  
Reply
post #6 of 9
Quote:
Originally Posted by SS_Patrick;13836964 
It's kinda like comparing apples to oranges. Javascript was created to aid HTML. PHP was created as a scripting language.

PHP is server side. Javascript/jquery is client side.

Up top, PHP does deal with SQL Databases. However it's abilities far out number just Databases
Thank gosh someone posted this.
To elaborate, PHP is executed on the server, and can access internal elements without (theoretically) exposing them to the rest of the world.

Javascript is executed in the client's browser, it cannot access internal elements of the server, and can be read in plain text by any user, unlike PHP which a user never sees.
For sale
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-920 Asus P6T Deluxe Asus GTX460 TOP 768mb G Skill ECO 1600 CAS7 1.35V 
Hard DriveOptical DriveOSMonitor
2x Vertex 60 GB raid[0] Asus DVDRW W7,Ubuntu 2 xAsus VH236H 
KeyboardPowerCaseMouse Pad
Razer Ultra X3 1000W HAF 932 My Desk 
  hide details  
Reply
For sale
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-920 Asus P6T Deluxe Asus GTX460 TOP 768mb G Skill ECO 1600 CAS7 1.35V 
Hard DriveOptical DriveOSMonitor
2x Vertex 60 GB raid[0] Asus DVDRW W7,Ubuntu 2 xAsus VH236H 
KeyboardPowerCaseMouse Pad
Razer Ultra X3 1000W HAF 932 My Desk 
  hide details  
Reply
post #7 of 9
+1 What dolphin and Patrick said.

PHP is server side. Javascript is client side.

So you can't really compare them.
post #8 of 9
Quote:
Originally Posted by Peachhunter12;13836734 
Is Javascript and PHP both worth learning? Also, what should I learn first?

Thanks...

Probably Javascript is easier to learn first, and easier to play around with. PHP requires you to set up a server. [although I'm sure there are alternatives]
post #9 of 9
Easy way to play with both is to use xampp which is an open source LAMP stack you just unzip or install depending on which version you download then startup xampp-control (windows) and then you can click on start for both PHP and MySQL and you have a pretty much instant server running on your desktop to play with PHP, MySQL, javascript etc.
White TITAN
(16 items)
 
   
CPUMotherboardGraphicsRAM
intel core i7-3770k Asus Z77 Sabertooth EVGA GTX 780 SC ACX Corsair Dominator Platinum 16GB (2x8GB) 
Hard DriveHard DriveHard DriveOptical Drive
Samsung 840 Pro  WD Black Crucial M4 LG Blueray 
CoolingOSMonitorPower
Swiftech H220 (Stock cooler on while RMA :( ) Windows 7 64bit Dell 2311h Ultrasharp x 2 Corsair AX850 
CaseMouseMouse PadAudio
Fractal Design Define R4 White (w/ Window) Logitech G700 Razer Control Edition Sound Blaster ZxR 
CPUMotherboardGraphicsRAM
Intel 980x Asus Rampage iii Extreme EVGA GTX580 SLI Patriot Viper Xtreme 12GB DDR3 2000 (PC3 16000) 
Hard DriveHard DriveHard DriveOptical Drive
120GB Corsair Force Series 3 SSD WD Caviar Black 640GB Crucial M4 128GB SSD LG Black Blu-ray Drive SATA Model UH12LS28 
CoolingCoolingCoolingCooling
XSPC RX360 and RX120 Rads Watercool HeatKiller 3.0 Limited Edition Black ... XSPC Dual Bay Res with Swiftech MCP655 Pump Silver Shining Bitspower Compression Fittings 
CoolingCoolingCoolingCooling
PrimoFlex Pro LRT Black Tubing -1/2in. ID X 3/4in. 3x Gentle Typhoon 120mm Fan 1850RPM (AP-15)  1x Noiseblocker NB-BlackSilentPro PL-2 120mm Ul... Koolance VID-NX580 Full Cover GPU Waterblock x2 
OSMonitorKeyboardPower
Windows 7 Home Premium x64 Dell U2311 Ultrasharp x2 Max Keyboard Nighthawk X8 Semi-Custom - Mechani... Antec High Current Gamer 900W 
CaseMouseMouse PadAudio
Xigmatek Elysium Black Logitech G700 Razer Goliathus Creative Sound Blaster Recon3D Fatal1ty Pro 
  hide details  
Reply
White TITAN
(16 items)
 
   
CPUMotherboardGraphicsRAM
intel core i7-3770k Asus Z77 Sabertooth EVGA GTX 780 SC ACX Corsair Dominator Platinum 16GB (2x8GB) 
Hard DriveHard DriveHard DriveOptical Drive
Samsung 840 Pro  WD Black Crucial M4 LG Blueray 
CoolingOSMonitorPower
Swiftech H220 (Stock cooler on while RMA :( ) Windows 7 64bit Dell 2311h Ultrasharp x 2 Corsair AX850 
CaseMouseMouse PadAudio
Fractal Design Define R4 White (w/ Window) Logitech G700 Razer Control Edition Sound Blaster ZxR 
CPUMotherboardGraphicsRAM
Intel 980x Asus Rampage iii Extreme EVGA GTX580 SLI Patriot Viper Xtreme 12GB DDR3 2000 (PC3 16000) 
Hard DriveHard DriveHard DriveOptical Drive
120GB Corsair Force Series 3 SSD WD Caviar Black 640GB Crucial M4 128GB SSD LG Black Blu-ray Drive SATA Model UH12LS28 
CoolingCoolingCoolingCooling
XSPC RX360 and RX120 Rads Watercool HeatKiller 3.0 Limited Edition Black ... XSPC Dual Bay Res with Swiftech MCP655 Pump Silver Shining Bitspower Compression Fittings 
CoolingCoolingCoolingCooling
PrimoFlex Pro LRT Black Tubing -1/2in. ID X 3/4in. 3x Gentle Typhoon 120mm Fan 1850RPM (AP-15)  1x Noiseblocker NB-BlackSilentPro PL-2 120mm Ul... Koolance VID-NX580 Full Cover GPU Waterblock x2 
OSMonitorKeyboardPower
Windows 7 Home Premium x64 Dell U2311 Ultrasharp x2 Max Keyboard Nighthawk X8 Semi-Custom - Mechani... Antec High Current Gamer 900W 
CaseMouseMouse PadAudio
Xigmatek Elysium Black Logitech G700 Razer Goliathus Creative Sound Blaster Recon3D Fatal1ty Pro 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Do Javascript and PHP have the same abilities?