Jump to content

Recommended Posts

Right hi all

First of all my problem is not how to use echo lol

my 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:&nbsp;</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:&nbsp;</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:&nbsp;</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:&nbsp;</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:&nbsp;</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 idea

any 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

A better way of storing the form code is in a function. Try this:

[code]

<?php

include 'config.php';

include 'header.php';

//form function

function 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:&nbsp;</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:&nbsp;</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:&nbsp;</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:&nbsp;</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:&nbsp;</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 form

print_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

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 into
http://www.evtecsolutions.com/main/register.php
I 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

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.