whare Posted January 18, 2007 Share Posted January 18, 2007 Right hi allFirst of all my problem is not how to use echo lolmy problem however it is not fuctioning correctly so here is my code[code]<?include 'config.php';include 'header.php'; $name = $_POST['name']; $email = $_POST['email']; $remail = $_POST['remail']; $pass = $_POST['pass']; $rpass = $_POST['rpass']; if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form$formcode = "<form method='POST' action='echo $_POST[PHP_SELF]'> <table border='0' width='300'> <tr> <td width='100%' colspan='2'><font face='Verdana' size='2'><b>User Registration</b></font></td> </tr> <tr> <td width='50%' align='right'><font face='Verdana' size='2'>Name: </font></td> <td width='50%'> <p><font face='Verdana' size='2'><input type='text' name='name' size='20'></font></p> </td> </tr> <tr> <td width='50%' align='right'><font face='Verdana' size='2'>E-Mail: </font></td> <td width='50%'><font face='Verdana' size='2'><input type='text' name='email' size='20'></font></td> </tr> <tr> <td width='50%' align='right'><font face='Verdana' size='2'>Repeat E-Mail: </font></td> <td width='50%'><font face='Verdana' size='2'><input type='text' name='remail' size='20'></font></td> </tr> <tr> <td width='50%' align='right'><font face='Verdana' size='2'>Password: </font></td> <td width='50%'><font face='Verdana' size='2'><input type='password' name='pass' size='20'></font></td> </tr> <tr> <td width='50%' align='right'><font face='Verdana' size='2'>Repeat Password: </font></td> <td width='50%'><font face='Verdana' size='2'><input type='password' name='rpass' size='20'></font></td> </tr> <tr> <td width='100%' colspan='2'> <p align='center'><input type='submit' value='Submit' name='submit'> <input type='reset' value='Reset' name='B2'></td> </tr> </table></form>"; echo "$formcode";} else { if((!$name) || (!$email) || (!$pass)){ echo 'You did not submit the following required information! <br />'; if(!$name){ echo "<B>Name</B> is a required field. Please enter it into the form.<br />"; $send = "no"; } if(!$email){ echo "<B>Email</B> is a required field. Please enter it into the form.<br />"; $send = "no"; } if(!$pass){ echo "<B>Password</B> is a required field. Please enter it into the form.<br />"; $send = "no"; } if ($pass != $rpass){ echo "Your passwords do not match please try again"; $send = "no"; } if ($email != $remail){ echo "Your email addesses do not natch please try again"; $remail_err = "no"; } $sql_email_check = mysql_query("SELECT email FROM is_members WHERE email='$email'"); $email_check = mysql_num_rows($sql_email_check); if($email_check > 0){ echo "<strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br />"; unset($email); $send = "no"; }} if ($send == "no"){ echo $formcode; } else { $pass = md5($pass); $sql = mysql_query("INSERT INTO is_members (name, email, pass, signup) VALUES('$name', '$email', '$pass', now())") or die (mysql_error()); if(!$sql){ echo 'There has been an error creating your account. Please contact the webmaster.';} else { $userid = mysql_insert_id(); // Let's mail the user! $subject = "Account Activation for $sitename"; $message = "Dear $name, Thank you for registering at our website, $url Please click the link below to activate your account $url/activate.php?id=$userid&code=$pass Once you have activated your account you may login using Username: $email Password: $rpass Thanks! Foto-Host Team This is an automated response, please do not reply!"; mail($email, $subject, $message, "From: $sitename<whare@evtecsolutions.com>\n X-Mailer: PHP/" . phpversion()); echo "Hello, ".$name.".<br />";echo "Activation Information has been sent to ".$email.", please follow it to activate your acount ";echo "Thankyou for choising ".$sitename.".<br />";}}} include 'footer.php';[/code]right now from what I can gather the problem is in line 85 or that area where it stats [code] if ($send == "no"){ echo $formcode; } else {[/code]what it is doing where it should display the form again or prosess the data for the db it is changing the current dir from "main" to "main/echo" now there is no such folder well Im sure you get the ideaany ideas how to better code this to stop this from happening?? Link to comment https://forums.phpfreaks.com/topic/34656-echo-problem/ Share on other sites More sharing options...
pocobueno1388 Posted January 18, 2007 Share Posted January 18, 2007 A better way of storing the form code is in a function. Try this:[code]<?phpinclude 'config.php';include 'header.php';//form functionfunction print_form(){ print<<<HERE<form method='POST' action='echo $_POST[PHP_SELF]'> <table border='0' width='300'> <tr> <td width='100%' colspan='2'><font face='Verdana' size='2'><b>User Registration</b></font></td> </tr> <tr> <td width='50%' align='right'><font face='Verdana' size='2'>Name: </font></td> <td width='50%'> <p><font face='Verdana' size='2'><input type='text' name='name' size='20'></font></p> </td> </tr> <tr> <td width='50%' align='right'><font face='Verdana' size='2'>E-Mail: </font></td> <td width='50%'><font face='Verdana' size='2'><input type='text' name='email' size='20'></font></td> </tr> <tr> <td width='50%' align='right'><font face='Verdana' size='2'>Repeat E-Mail: </font></td> <td width='50%'><font face='Verdana' size='2'><input type='text' name='remail' size='20'></font></td> </tr> <tr> <td width='50%' align='right'><font face='Verdana' size='2'>Password: </font></td> <td width='50%'><font face='Verdana' size='2'><input type='password' name='pass' size='20'></font></td> </tr> <tr> <td width='50%' align='right'><font face='Verdana' size='2'>Repeat Password: </font></td> <td width='50%'><font face='Verdana' size='2'><input type='password' name='rpass' size='20'></font></td> </tr> <tr> <td width='100%' colspan='2'> <p align='center'><input type='submit' value='Submit' name='submit'> <input type='reset' value='Reset' name='B2'></td> </tr> </table></form> HERE;}//end form $name = $_POST['name']; $email = $_POST['email']; $remail = $_POST['remail']; $pass = $_POST['pass']; $rpass = $_POST['rpass']; if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the formprint_form();} else { if((!$name) || (!$email) || (!$pass)){ echo 'You did not submit the following required information! <br />'; if(!$name){ echo "<B>Name</B> is a required field. Please enter it into the form.<br />"; $send = "no"; } if(!$email){ echo "<B>Email</B> is a required field. Please enter it into the form.<br />"; $send = "no"; } if(!$pass){ echo "<B>Password</B> is a required field. Please enter it into the form.<br />"; $send = "no"; } if ($pass != $rpass){ echo "Your passwords do not match please try again"; $send = "no"; } if ($email != $remail){ echo "Your email addesses do not natch please try again"; $remail_err = "no"; } $sql_email_check = mysql_query("SELECT email FROM is_members WHERE email='$email'"); $email_check = mysql_num_rows($sql_email_check); if($email_check > 0){ echo "<strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br />"; unset($email); $send = "no"; }}if ($send == "no"){print_form();} else { $pass = md5($pass); $sql = mysql_query("INSERT INTO is_members (name, email, pass, signup) VALUES('$name', '$email', '$pass', now())") or die (mysql_error()); if(!$sql){ echo 'There has been an error creating your account. Please contact the webmaster.';} else { $userid = mysql_insert_id(); // Let's mail the user! $subject = "Account Activation for $sitename"; $message = "Dear $name, Thank you for registering at our website, $url Please click the link below to activate your account $url/activate.php?id=$userid&code=$pass Once you have activated your account you may login using Username: $email Password: $rpass Thanks! Foto-Host Team This is an automated response, please do not reply!"; mail($email, $subject, $message, "From: $sitename<whare@evtecsolutions.com>\n X-Mailer: PHP/" . phpversion()); echo "Hello, ".$name.".<br />";echo "Activation Information has been sent to ".$email.", please follow it to activate your acount ";echo "Thankyou for choising ".$sitename.".<br />";}}} include 'footer.php';?>[/code] Link to comment https://forums.phpfreaks.com/topic/34656-echo-problem/#findComment-163318 Share on other sites More sharing options...
whare Posted January 18, 2007 Author Share Posted January 18, 2007 Thanx for the code I changed it for that but still getting the echo problem ??? ???check it for yourself @ www.evtecsolutions.com/main/regster.php and you should see what I mean Link to comment https://forums.phpfreaks.com/topic/34656-echo-problem/#findComment-163326 Share on other sites More sharing options...
Philip Posted January 18, 2007 Share Posted January 18, 2007 You have echo "$formcode";it should beecho $formcode; Link to comment https://forums.phpfreaks.com/topic/34656-echo-problem/#findComment-163329 Share on other sites More sharing options...
whare Posted January 18, 2007 Author Share Posted January 18, 2007 changed the code to pocobueno1388 example that uses function but still have the problem :( Link to comment https://forums.phpfreaks.com/topic/34656-echo-problem/#findComment-163338 Share on other sites More sharing options...
anatak Posted January 18, 2007 Share Posted January 18, 2007 change the link to[quote author=whare link=topic=122897.msg507443#msg507443 date=1169082291]Thanx for the code I changed it for that but still getting the echo problem ??? ???check it for yourself @ www.evtecsolutions.com/main/regster.php and you should see what I mean[/quote]change the link intohttp://www.evtecsolutions.com/main/register.phpI do not get any errors. is this solved ? Link to comment https://forums.phpfreaks.com/topic/34656-echo-problem/#findComment-163340 Share on other sites More sharing options...
whare Posted January 18, 2007 Author Share Posted January 18, 2007 Thanx for solving my typo loldid you try running the script (registering)?Coz I am still getting the problem Link to comment https://forums.phpfreaks.com/topic/34656-echo-problem/#findComment-163343 Share on other sites More sharing options...
Philip Posted January 18, 2007 Share Posted January 18, 2007 <form method='POST' action='echo $_POST[PHP_SELF]'>Should be <form method='POST' action='".$_POST[PHP_SELF]."'> Link to comment https://forums.phpfreaks.com/topic/34656-echo-problem/#findComment-163368 Share on other sites More sharing options...
whare Posted January 18, 2007 Author Share Posted January 18, 2007 Thanx philip Bad coding rules again lolwell it works now sort of I got to figer out why the error checking is not working now Link to comment https://forums.phpfreaks.com/topic/34656-echo-problem/#findComment-163579 Share on other sites More sharing options...
Recommended Posts