Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Really need help here!!
Old 07-26-2004, 04:09 PM Really need help here!!
Novice Talker

Posts: 13
Trades: 0
I'm really new to this and i'm grasping the concept but i don't have enough knowledge of the functions and process to know how it works!


I'm getting this from a registration script that registers a user to a myPHPadmin database:

Fatal error: Cannot redeclare is_valid_email() (previously declared in /web2/ltsn-ics/pub/italics/register.php:54) in /web2/ltsn-ics/pub/italics/register.php on line 54)

I've tried to do as much of this myself as possible but i'm confused as to what way I should be doing this. Right now I have an HTML form posting to a PHP file which is supposed to update the database, return an error (with the form and variables attached) or send up a thanks screen if everything is ok.

Right now if it's not entering blank entries into the database it's just not working at all. I'm not quite sure what the "include" line in the example i was given does especially when my form is in an HTML file.

If i could even get some pointers that would be great! I've attached the PHP file if anyone's looking for a laugh!!
Attached Files
File Type: txt php.txt (4.0 KB, 9 views)

Last edited by coalduststar; 07-26-2004 at 04:12 PM..
coalduststar is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-26-2004, 04:23 PM
Calash's Avatar
Super Talker

Posts: 104
Trades: 0
I think the problem may be at line 94, where it seems to include it's self again.

I am assuming that you are using a HTML form and then having this PHP be the form processor. If this is correct then there is no reason to have that include. Try changing every point that says "include register.php" to include yourpage.html where yourpage is the form. This is not the best fix but it should help isolate the problem.
__________________

Please login or register to view this content. Registration is FREE
Calash is offline
Reply With Quote
View Public Profile Visit Calash's homepage!
 
Old 07-26-2004, 04:26 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Use the include_once() method instead of include to ensure that embedded double includes don't occur.
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 07-26-2004, 04:38 PM
Novice Talker

Posts: 13
Trades: 0
i'll give it a shot but - I sorta bunged that in there cos it was in an example code I got but it's totally out of context by the look of things!
coalduststar is offline
Reply With Quote
View Public Profile
 
Old 07-26-2004, 04:40 PM
Novice Talker

Posts: 13
Trades: 0
Fatal error: Cannot redeclare is_valid_email() (previously declared in /web2/ltsn-ics/pub/italics/register.php:54) in /web2/ltsn-ics/pub/italics/register.php on line 54

is that the result of all the include stuff that shouldn't be there??
coalduststar is offline
Reply With Quote
View Public Profile
 
Old 07-26-2004, 04:51 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
PHP Code:
<?php

//variablize the crap out of everything-- i just made that word up!
$title $_POST['title'];
$name $_POST['name'];
$sname $_POST['sname'];
$pos $_POST['pos'];
$dept $_POST['dept'];
$inst $_POST['inst'];
$address $_POST['address'];
$city $_POST['city'];
$country $_POST['country'];
$postcode $_POST['postcode'];
$phone $_POST['phone'];
$fax $_POST['fax'];
$email $_POST['email'];
$url $_POST['url'];
$teach_area $_POST['teach_area'];
$review_paper $_POST['review_paper'];
$mail_list $_POST['mail_list'];
$comp_sci $_POST['comp_sci'];
$ILS $_POST['ILS'];
$edu_dev $_POST['edu_dev'];

//error variables

$fail 0;
$fail1 0;
$fail2 0;
$fail3 0;
$fail4 0;
$email2c 0;
$username2c 0;
$error2c 0;
$error '';
$error1 '';
$error2 '';
$error3 '';
$error4 '';
$email2 '';
$username2 '';
$error2 '';
$fail5 0;
$error5 '';
$success 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
?>




<?php
//email validation
function is_valid_email($email) {
    if(
ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)"$email)) {
            return 
1;
    } else {
        return 
0;
    }


    if (
is_valid_email($email) != 1) { 
    
    echo(
"Please make sure that your email address is valid!");
    
    include 
'register.php';
    exit();
    }
   
/* Do some error checking on the form posted fields */

if((!$name) || (!$sname) || (!$email) || (!$address) || (!$pos)){
    
$error '<font face="Tahoma">Error!<br />';
    
$fail 1;
    if(!
$name){
        
$error1 '<font face="Tahoma"><font color="#FF0000"><strong>First Name is a required field. Please enter it above.<br /><br />';
        
$fail1 1;
    }
    if(!
$sname){
        
$error2 '<font face="Tahoma"><font color="#FF0000"><strong>Last Name is a required field. Please enter it above.<br /><br />';
        
$fail2 1;
    }
    if(!
$email){
        
$error3 '<font face="Tahoma"><font color="#FF0000"><strong>Email Address is a required field. Please enter it above.<br /><br />';
        
$fail3 1;
    }
    if(!
$address){
        
$error4 '<font face="Tahoma"><font color="#FF0000"><strong>Desired Username is a required field. Please enter it above.<br /><br />';
        
$fail4 1;
    }
    if(
$terms == false){
        
$error5 '<font face="Tahoma"><font color="#FF0000"><strong>You must agree to the Terms of Service.<br /><br />';
        
$fail5 1;
    }
    include 
'register.php'// Show the form again!
    /* End the error checking and if everything is ok, we'll move on to
     creating the user account */
    
exit(); // if the error checking has failed, we'll exit the script!
}
    
/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */

 
$sql_email_check mysql_query("SELECT email FROM italics WHERE email='$email'");

 
$email_check mysql_num_rows($sql_email_check);

 if((
$email_check 0)){
    
$error2 '<font face="Tahoma">Please fix the following errors: <br />';
    
$error2c 1;
    if(
$email_check 0){
        
$email2 '<font face="Tahoma"><font color="#FF0000"><strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br /><br />';
        
$email2c 1;
        unset(
$email);
    }
    include 
'register.php'// Show the form again!
     
exit();  // exit the script so that we do not create this account!
 
}


//update database

mysql_connect ('online.ulst.ac.uk''ltsn','ics' );
mysql_select_db (ltsn);
mysql_query ("INSERT INTO italics (title, name, sname, pos, dept, inst, address, city, country, postcode, phone, fax, email, url, teach_area, review_paper, mail_list, comp_sci, ILS, edu_dev) VALUES ('$title', '$name', '$sname', '$pos', '$dept', '$inst', '$address', '$city', '$country', '$postcode', '$phone', '$fax', '$email', '$url', '$teach_area', '$review_paper', '$mail_list', '$comp_sci', '$ILS', '$edu_dev') ");

?>
There that will help a little. I will look at it later when I get home probably.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 07-26-2004, 04:56 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Wow, before I even finished you all had already answered.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 07-26-2004, 05:05 PM
Novice Talker

Posts: 13
Trades: 0
thanks man- i've removed all the include stuff cos altho i want it to keep the form if it finds an error, it's causing all sorts of problems- so the include thing returns the form back to you without the variables?

if i take out include then the email validation works but it won't check for the email accounts on the database- just returns a blank screen!
coalduststar is offline
Reply With Quote
View Public Profile
 
Old 07-26-2004, 09:57 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Calash is right. If the code you posted is actually in the file called Register.php, then you have a recursive include and that is not a good design at all. Put EVERYTHING into functions and then make function calls as you need them.

The simple reason you're getting the error is because the PHP processor attempts to reinclude the file into the file itself, creating double everything, including the function definition of is_valid_email().
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 07-27-2004, 06:18 AM
Novice Talker

Posts: 13
Trades: 0
thanks
coalduststar is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Really need help here!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30537 seconds with 13 queries