newbie

This is a discussion on newbie within the PHP Language forums, part of the PHP Programming Forums category; Hi at all, I'm newbie in php and I'm searching to make function one project that I found ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-18-2007
cory
 
Posts: n/a
Default newbie

Hi at all, I'm newbie in php and I'm searching to make function one
project that I found in a school book, the project is ok because it
functions a part some script. I'd like to know which is the error.
I'm working on win xp pro and on it I have installed a server apache
ver.2.2.4
php ver. 5.2.4, mysql server and client ver.
3.23

I report you the problem:
When I compile the form, my data that I fill in, it has not
processed.The thing strange is that when I change version of Apache,
version of php, And version of mysql the problem becomes another in
other words is another script that don't go.
here is the script:

<?
include ("admin/config.php");
include ("admin/users.php");

################################################## ######
## NEW MEMBER REGISTER
################################################## ######
if($register=="Register New Member"){


//****************************
// CHECK FOR USER AND EMAIL **
//****************************

$SELECT_USERS = mysql_query("SELECT * FROM users WHERE
Username='$username'",$db);
$USER_EXISTS = mysql_num_rows($SELECT_USERS);

$SELECT_EMAILS = mysql_query("SELECT * FROM users WHERE
Email='$email'",$db);
$EMAIL_EXISTS = mysql_num_rows($SELECT_EMAILS);



//******************
// BEGIN CHECK **
//******************

if(strlen($firstname)<3){$msg[1] = "Firstname too short";}
if(strlen($surname)<3) {$msg[2] = "Surname too short";}
if(strlen($telephone)<6){$msg[3] = "Not a valid phone number";}
if(strlen($email)<3) {$msg[4] = "Not a valid e-mail address";}
if(strlen($address)<10) {$msg[5] = "Address is too short";}
if(strlen($city)<3) {$msg[6] = "City name too short";}
if(strlen($postcode)<4) {$msg[7] = "Postcode too short";}
if(strlen($country)<3) {$msg[8] = "Country too short";}

if($EMAIL_EXISTS) {$msg[4] = "E-mail already exists";}

if(strlen($username)<3) {$msg_user = "Very short username";}

if($USER_EXISTS) {$msg_user = "Username already exists";}
else{$user_ok = 1;}

if(strlen($password)<6) {$msg_pass = "Please use more than 6
characters";}
else{$pass_ok = 1;}

if((count($msg)!= 0)||(!$user_ok)||(!$pass_ok)) {$msg[0] = "Error on
creating new account";}
else{$details_ok = 1;}


//*****************************
// SUCCESSIVE REGISTRATION **
//*****************************

if(($details_ok)&&($user_ok)&&($pass_ok)){

$md5_password = md5($password);

$INSERT = mysql_query("INSERT INTO users (
Username,
Password,
Firstname,
Surname,
Company,
Address,
City,
County,
Postcode,
Country,
Telephone,
Mobile,
Fax,
Email
)

VALUES (
'$username',
'$md5_password',
'$firstname',
'$surname',
'$company',
'$address',
'$city',
'$county',
'$postcode',
'$country',
'$telephone',
'$mobile',
'$fax',
'$email'
)",$db);

if($INSERT){$meta_next = "<META HTTP-EQUIV='REFRESH' CONTENT='1;
URL=products.php'>";
$msg[0]= "Thank You!";


//*****************************
// INSERT CARDHOLDER DETAILS **
//*****************************
$INSERT_CARDHOLDER = mysql_query("INSERT INTO cardholders (

Username,
Firstname,
Surname,
Address,
City,
Postcode,
Country,
Telephone,
Email,
Mobile,
Fax,
Cardtype,
Cardname,
Cardnumber,
Cardexpire
)

VALUES (
'$username',
'$firstname',
'$surname',
'$address',
'$city',
'$postcode',
'$country',
'$telephone',
'$email',
'$mobile',
'$fax',
'$cardtype',
'$username',
'$cardnumber',
'$cardexpire'
)",$db);

if($INSERT_CARDHOLDER){$msg_cardholder = "Done!";}
else{$msg_cardholder = "Error";}


//*****************************
// INSERT SHIPPING DETAILS **
//*****************************
$INSERT_SHIPPING = mysql_query("INSERT INTO shipping (

Username,
Firstname,
Surname,
Address,
City,
Postcode,
Country,
Telephone
)

VALUES (
'$username',
'$firstname',
'$surname',
'$address',
'$city',
'$postcode',
'$country',
'$telephone'
)",$db);

if($INSERT_SHIPPING){$msg_shipping = "Done!";}
else{$msg_shipping = "Error";}


//************************************************** *
//REPLACE ANONYMOUS ITEM SELECTIONS/NORMAL USERNAME *
//************************************************** *

$SELECT_ITEMS = mysql_query("SELECT * FROM cart WHERE
Username='$user'",$db);
$DELETE_USER = mysql_query("DELETE FROM users_anonymous WHERE
IDName='$user'",$db);

while($item = mysql_fetch_array($SELECT_ITEMS)){

$UPDATE_ITEMS = mysql_query("UPDATE cart SET
Username ='$username',
Date ='$tdate'
WHERE Username='$user'",$db);
}

//************************************************** *
//MAKES THE USER A MEMBER *
//************************************************** *

$loggedin=1;
$set_cookie = setcookie ("customer","$username",time()+2600000);


}
else{$meta_next = NULL;}
}

}

?>

<html>
<head>
<title><?=$conf[title];?></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<?=$meta_next;?>

<link rel="stylesheet" href="style.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<table width="800" border="0" cellspacing="0" cellpadding="0"
height="575">
<tr bgcolor="#8F97AF">
<td colspan="4" height="58"><img src="images/logo_1.gif"
width="190" height="101"></td>
</tr>
<tr>
<td colspan="4" height="1" bgcolor="#FFFFFF"></td>
</tr>
<tr>
<td height="16" bgcolor="#336699" width="122"></td>
<td height="24" bgcolor="#336699" width="478"> &nbsp;&nbsp;
<?include("menu_links.php");?>
</td>
<td height="26" rowspan="2" valign="bottom" bgcolor="#336699"
width="26" align="right">
<img src="images/corner.gif"></td>
<td height="26" rowspan="2" bgcolor="#336699" width="174"
align="center" class="text_small_1"><font color="#FFFFFF">
<?if($loggedin){echo "Hello $user";}?>
</font></td>
</tr>
<tr>
<td width="122" valign="top" rowspan="2"><img src="images/
hi_contrast_side2.gif" width="122" height="501"></td>
<td width="478" height="11"><img src="images/corner2.gif"
width="10" height="10"></td>
</tr>
<tr>
<td height="506" colspan="2" valign="top"> <br>
<form name="form1" method="post" action="<?=$PHP_SELF;?>">
<span class="menu_1"><b><font color="#F5F5F5" size="5"><span
class="menu_1"><b><font color="#F5F5F5" size="5">&nbsp;&nbsp;</font></
b></span>REGISTER</font></b></span>
<table width="479" border="0" cellspacing="0" cellpadding="3"
height="168" align="center">
<tr bgcolor="#F8F8F8">
<td valign="top" height="271" align="center"> <br>
<table width="100%" border="0" cellspacing="0"
cellpadding="3" class="text_small_1">
<tr>
<td bgcolor="#CCCCCC">Personal Member Details:<span
class="register">
<?=$msg[0];?>
</span></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"></td>
</tr>
</table>
<br>
<table width="96%" border="0" cellspacing="0"
cellpadding="3" height="78" bgcolor="#ECEEF0">
<tr>
<td class="text_small_4" height="21"
width="21%">Firstname:</td>
<td class="register" height="21" width="79%">
<input type="text" name="firstname" class="boxes"
value="<?=$firstname;?>">
*
<?=$msg[1];?>
</td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%">Surname:</td>
<td class="register" height="21" width="79%">
<input type="text" name="surname" class="boxes"
value="<?=$surname;?>">
*
<?=$msg[2];?>
</td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%">Company:</td>
<td class="register" height="21" width="79%">
<input type="text" name="company" class="boxes"
value="<?=$company;?>">
</td>
</tr>
<tr>
<td colspan="2" class="text_small_1" height="4"
background="images/seprow.gif"></td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%">Address:</td>
<td class="register" height="21" width="79%">
<textarea name="address" class="boxes" rows="5"
cols="30"><?=$address;?></textarea>
*
<?=$msg[5];?>
</td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%">City:</td>
<td class="register" height="21" width="79%">
<input type="text" name="city" class="boxes"
value="<?=$city;?>">
*
<?=$msg[6];?>
</td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%">Postcode:</td>
<td class="register" height="21" width="79%">
<input type="text" name="postcode" class="boxes"
value="<?=$postcode;?>">
*
<?=$msg[7];?>
</td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%">Country:</td>
<td class="register" height="21" width="79%">
<input type="text" name="country" class="boxes"
value="<?=$country;?>">
*
<?=$msg[8];?>
</td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%">Telephone:</td>
<td class="register" height="21" width="79%">
<input type="text" name="telephone" class="boxes"
value="<?=$telephone;?>">
*
<?=$msg[3];?>
</td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%">Mobile:</td>
<td class="register" height="21" width="79%">
<input type="text" name="mobile" class="boxes"
value="<?=$mobile;?>">
</td>
</tr>
<tr>
<td class="text_small_4" height="8"
width="21%">Fax:</td>
<td class="register" height="8" width="79%">
<input type="text" name="fax" class="boxes"
value="<?=$fax;?>">
</td>
</tr>
<tr>
<td class="text_small_4" height="21" width="21%">E-
mail:</td>
<td class="register" height="21" width="79%">
<input type="text" name="email" class="boxes"
value="<?=$email;?>">
*
<?=$msg[4];?>
</td>
</tr>
<tr>
<td colspan="2" class="text_small_1" height="4"
background="images/seprow.gif"></td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%"><b>Username:</b></td>
<td class="register" height="21" width="79%">
<input type="text" name="username" class="boxes"
value="<?=$username;?>">
*
<?=$msg_user;?>
</td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%"><b>Password:</b></td>
<td class="register" height="21" width="79%">
<input type="password" name="password"
class="boxes">
*
<?=$msg_pass;?>
</td>
</tr>
<tr>
<td colspan="2" class="text_small_1" height="4"
background="images/seprow.gif"></td>
</tr>
<tr>
<td class="text_small_4" height="21"
width="21%">Mailing list?</td>
<td class="text_small_3" height="21" width="79%">
<input type="checkbox" name="mlist" value="1"
checked>
<span class="text_small_1"> Receive any latest
news on your
e-mail!</span></td>
</tr>
<tr>
<td valign="top" class="text_small_1" height="4"
bgcolor="#E6E6E6">
</td>
<td valign="top" class="text_small_1" height="4"
bgcolor="#E6E6E6">
<input type="submit" name="register"
value="Register New Member" class="buttons">
<input type="reset" name="Submit4" value="Reset
Details" class="buttons">
</td>
</tr>
<tr>
<td valign="top" class="text_small_1" height="4"
colspan="2" bgcolor="#E6E6E6"></td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td bgcolor="#F8F8F8" class="text_small_1" height="29"> <a
href="index.php">
</a> </td>
</tr>
</table>
<br>
</form>
<div align="center">
<?=$conf[footer];?>
<br>
</div>
<br>
</td>
<td align="center" height="506" valign="top" bgcolor="#F5F5F5"
width="174">
<br>
<?include ("menu_groups.php");?>
</td>
</tr>
</table>
</body>
</html>

Reply With Quote
  #2 (permalink)  
Old 09-18-2007
Jerry Stuckle
 
Posts: n/a
Default Re: newbie

cory wrote:
> Hi at all, I'm newbie in php and I'm searching to make function one
> project that I found in a school book, the project is ok because it
> functions a part some script. I'd like to know which is the error.
> I'm working on win xp pro and on it I have installed a server apache
> ver.2.2.4
> php ver. 5.2.4, mysql server and client ver.
> 3.23
>
> I report you the problem:
> When I compile the form, my data that I fill in, it has not
> processed.The thing strange is that when I change version of Apache,
> version of php, And version of mysql the problem becomes another in
> other words is another script that don't go.
> here is the script:
>


<lots of code snipped>

Please do not multi-post. Cross-post instead, if you must.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #3 (permalink)  
Old 09-18-2007
Lammi
 
Posts: n/a
Default Re: newbie

that code will never work on php5 or 4 , if you're not editing
php.ini. your script uses globals, that are de-activated by default
sind php4.
you're using short tags, that must be activated in php.ini too (they
are activated by default i think).

php-code isn't compiled ever. it's parsed.

it would be extremly useful if you post the errormessage instead of
loads of html.

Reply With Quote
  #4 (permalink)  
Old 09-18-2007
Michael Fesser
 
Posts: n/a
Default Re: newbie

..oO(Lammi)

>php-code isn't compiled ever.


PHP code is compiled into a bytecode, which is then interpreted by the
Zend engine. Code caches are able to keep the compiled code in memory to
speed up the script execution.

>it's parsed.


Parsing is one of the steps that have to be done before code can be
compiled.

Micha
Reply With Quote
  #5 (permalink)  
Old 09-18-2007
Jerry Stuckle
 
Posts: n/a
Default Re: newbie

Michael Fesser wrote:
> .oO(Lammi)
>
>> php-code isn't compiled ever.

>
> PHP code is compiled into a bytecode, which is then interpreted by the
> Zend engine. Code caches are able to keep the compiled code in memory to
> speed up the script execution.
>
>> it's parsed.

>
> Parsing is one of the steps that have to be done before code can be
> compiled.
>
> Micha


Nope, Lammi is correct. PHP code is not compiled, it is parsed. It may
or may not be stored as byte code.

Not even Zend claims PHP is compiled.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #6 (permalink)  
Old 09-18-2007
Michael Fesser
 
Posts: n/a
Default Re: newbie

..oO(Jerry Stuckle)

>Nope, Lammi is correct. PHP code is not compiled, it is parsed. It may
> or may not be stored as byte code.


The parser is just a part of the entire process.

>Not even Zend claims PHP is compiled.


| [...] The Web Server Disk retrieves the code for the PHP-based web
| page and sends the PHP code to the Run-time Compiler. (3). The Zend
| Engine Run-time Compiler creates an compiled representation of the
| script, which is passed on to the Zend Engine Executor. [...]

(from <http://www.zend.com/zend/technology.php>)

There's even the special function __halt_compiler().

Micha
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:17 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0