מציק ביותר

Mr Boggy Man

New member
מציק ביותר

שימו לב למה שאני עושה:
<html> </html><head> <title>Test</title> </head> <body> <form action=<?PHP print $PHP_SELF;?>"> <input type=text name="user"> <input type=submit value="Click Here"> </form> <?php print "Welcome $user"; ?> </body><head><title>Test</title></head><body><form action=<?PHP print $PHP_SELF;?>"><input type=text name="user"><input type=submit value="Click Here"></form><?php print "Welcome $user";?></body><html>​
וזה לא עובד לי...למישהו יש מושג? (זה מראה Welcome ואחרי זה כלום...)
 

Mr Boggy Man

New member
תיקון:

<html> <head> <title>Test</title> </head> <body> <form action="test.php" methos=post> <input type=text name="user" size=15 value=user> <input type=submit value="Click Here"> </form> <?php print "Welcome $user"; ?> </body> </html>​
 

Megapuzik

New member
גישה לאלמנטים מטופס

כל האלמנטים נמצאים במערך $_POST זאת אומרת שבדוגמא שלך כאשר שם הלמנט הוא user אתה צריך לעשות :
print $_POST[´user´];​
טיפ : תעשה תנאי שיבדוק אם מישהו כתב משהו או לא
if( !empty($_POST[´user´]) ) { print $_POST[´user´]; } else { print"נא למלאות שם"; }​
בהצלחה.
 

Mr Boggy Man

New member
עוד בעיה P:

שימו לב:
<?php $link function connectToDB() { global $link; $link = mysql_connect( "localhost", "root", "mypass" ); if ( ! $link ) die("Couldn´t connect to the database"); mysql_select_db("organizer", $link ) or die ("Couldn´t open database: ".mysql_error() ); } connectToDB(); ?> זה אומר לי: Parse error: parse error, unexpected T_FUNCTION in /var/www/html/test/dblib.inc on line 3 מה לעשות?​
 

Megapuzik

New member
-

תעיף את ה$link מחוץ לפונקציה וכמובן אל תקרא לזה גלובאלית מחוץ לפונקציה. בPHP אתה לא חייב להצהיר על משתנים לפני שימושם.
 

Mr Boggy Man

New member
תודה רבה! אבל יש עוד בעיה :-}

טוב...מישומה המשתנה massage לא נראה ולא נשמע איפה שהוא צריך להיות P:
<?php include("dblib.inc"); include("clublib.inc"); if ( isset( $actionflag )&& $actionflag == "join" ) { if ( empty( $form[login] ) || empty( $form[password] ) || empty( $form[password] ) ) $massage = "you must fill in all fields<BR>\n"; if ( $form[password] != $form[password2] ) $massage = "Yopur passwords did not match<BR>\n"; if ( strlen( $form[password] > 8 ) ) $massage = "Your password must be less than 8 characters<BR>\n"; if( strlen( $form[login] ) > 8 ) $massage = "Your login must be less than 8 characters\n"; if( getRow("clubs", "login", $form[login]) ) $massage = "Login \"$form[login]\" alredy exists. Try another one<BR>\n"; if ( $massage == "" ) { $id = newUser( $form[login], $form[password] ); cleanMemberSession( $id, $form[login], $form[password] ); header( "Location: updateclub.php?".SID ); exist; } } ?> <html> <head> <title>Join TEST</title> </head> <body> <?php include("publicnav.inc"); ?> <p> <h1>JOIN</H1> <?php { print "$massage"; } ?> <p> <form action="<?php print $PHP_SELF;?>"> <input type="hidden" name="actionflag" value="join"> <input type="hidden" name="<?php print session_name() ?>" value="<?php print session_id() ?>"> Login: <BR> <input type="text" name="form[login]" value="<?php print $form[login] ?>" maxlengh=8> </p> <p> Password: <BR> <input type="password" name="form[password" maxlengh=8> </p> <p> Confirm password: <BR> <input type="password" name="forn[password2]" maxlengh=8> </p> <p> <input type=submit value=update> </p> </form> </body> </html>​
 

Megapuzik

New member
תראה, איש...

זרקת פה כמה שורות של קוד לא נראה לי יהיו פה אנשים שיעיינו לך בכל הקוד, ומה שיותר אירוני זה שאפילו לא אמרת מה הבעיה. תחשוב טוב טוב מה הבעיה, תראה את השורות הרלוונטיות ותספר לנו מה הבעיה, ככה נעזור יותר.
 

Mr Boggy Man

New member
אני צריך לשכתב הכל...

אני עובד עם ספר, ויש בו מספר שגיאות מאוד גדול. לכן אני צריך לשכתב הכל ולעשות זאת בצורה שלי...לא רציני, אבל מעצבן P:
 

matroz

New member
do this

instead of writing : print "$massage"; write print $massage; or even better echo $massage; there is no need for the quotes if your not using a string.
 
למעלה