Jump to content

Retrieve same message from other php files :)


shebbycs

Recommended Posts

Submit2.php

 

<?php

$db = mysql_connect("localhost", "root") or die("Could not connect."); //username and password

if(!$db) 

die("no db");

if(!mysql_select_db("simple",$db))
if(!mysql_select_db("regis",$db))//database name

	die("No database selected.");
$message=$_POST['message'];
if(isset($_POST['submit'])) //if submit button push has been detected

{

   $message=$_POST['message'];

   if(strlen($message)<1)

   {

      print "You did not input a message";

   }

   else

   {

      $message=strip_tags($message);

      $IP=$_SERVER["REMOTE_ADDR"]; //grabs poster's IP

      $checkforbanned="SELECT IP from admin where IP='$IP'";

      $checkforbanned2=mysql_query($checkforbanned) or die("Could not check for banned IPS");

      if(mysql_num_rows($checkforbanned2)>0) //IP is in the banned list

      {

         print "You IP is banned from posting.";

      }

     else
      
       if(strlen($message)>=1)
       {

         $message=strip_tags($message);
         echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$message')</SCRIPT>");
         die("<meta http-equiv=\"refresh\" content=\"0; url=registration.php\">");
       }
        $message=$_POST['message'];
         $message=strip_tags($message);
     /*   if($_POST['username'] && $_POST['pass'])
       {

         $name = mysql_query("SELECT * FROM Persons");
         $thedate = date("U"); //grab date and time of the post

         $insertmessage="INSERT into mesej (name,IP,postime,message) values('$name','$IP','$thedate','$message')";

         mysql_query($insertmessage) or die("Could not insert message");

        }     */

   }
}

if(!isset($message))
{
  print "<form action='' method='post' name='form'>";

  print "Your message:<br>";

  print "<textarea name='message' cols='40' rows='2'></textarea><br>";

  print "<a onClick=\"addSmiley('')\"><img src='smile.gif'></a> ";

  print "<a onClick=\"addSmiley('')\"><img src='blush.gif'></a> ";

  print "<a onClick=\"addSmiley('')\"><img src='images/wink.gif'></a> ";

  print "<input type='submit' name='submit' value='Set Name'></form>";

  print "<script language=\"Java Script\" type=\"text/javascript\">\n";

  print "function addSmiley(a)\n";

  print "{\n";

  print "document.form.message.value += a;";

  print "document.form.message.focus();\n";

  print "}\n";

  print "</script>\n";

  print "<br><br>";

}



?>

 

 

Registration.php

<?php

$db = mysql_connect("localhost", "root") or die("Could not connect."); //username and password

if(!$db){die("no db");}
if(!mysql_select_db("regis",$db)){die("No database selected.");}
$message=$_POST['message'];
echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$message')</SCRIPT>");
if (isset($_POST['sub']))
         {
          $message=strip_tags($message);



        if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] )
        {
           print  "You did not complete all of the required fields";
        }

        // checks if the username is in use

        if (!get_magic_quotes_gpc())
       {
        $_POST['username'] = addslashes($_POST['username']);
       }

        $usercheck = $_POST['username'];

        $check = mysql_query("SELECT username FROM registration WHERE username = '$usercheck'")

         or die(mysql_error());

        $check2 = mysql_num_rows($check);

        
       //if the name exists it gives an error

       if ($check2 != 0)
      {
       print ('Sorry, the username '.$_POST['username'].' is already in use.');
      }


       //this makes sure both passwords entered match

       if ($_POST['pass'] != $_POST['pass2'])
      {
       print ('Your passwords did not match. ');
      }

      // here we encrypt the password and add slashes if needed

       $_POST['pass'] = md5($_POST['pass']);

       if (!get_magic_quotes_gpc())
      {
       $_POST['pass'] = addslashes($_POST['pass']);

       $_POST['username'] = addslashes($_POST['username']);
      }

      // now we insert it into the database

     if($_POST['username'] && $_POST['pass'] && $_POST['pass2'] )
     {
     $insert = "INSERT INTO registration (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
     $add_member = mysql_query($insert);

     echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('Registration had been succesfully added ')</SCRIPT>");
     print("<meta http-equiv=\"refresh\" content=\"0; url=login.php\">");
     }

   }


else
{
  echo "<form action='registration.php' method='post'>

  <table border='0'>

  <tr><td>Username:</td><td>

  <input type='text'name='username' maxlength='60'>

  </td></tr>

  <tr><td>Password:</td><td>

  <input type='password' name='pass' maxlength='10'>

  </td></tr>

  <tr><td>Confirm Password:</td><td>

  <input type='password' name='pass2' maxlength='10'>

  </td></tr>

  <tr><th colspan=2><input type='submit' name='sub' value='Register'></th></tr> </table>

  </form> ";
}

 

im just want the message text area to be appear in registhration php in text box but its doest not appear instead the output is empty when im testing the first one that is :

 

  if(strlen($message)>=1)

      {

 

        $message=strip_tags($message);

        echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$message')</SCRIPT>");

        die("<meta http-equiv=\"refresh\" content=\"0; url=registration.php\">");

 

that javascript box can run and read the same message that was input but when come to registrtaion php its only empty which way im wrong ?

?>

Link to comment
Share on other sites

<?php

$db = mysql_connect("localhost", "root") or die("Could not connect."); //username and password

if(!$db) 

die("no db");

if(!mysql_select_db("simple",$db))
if(!mysql_select_db("regis",$db)) die("No database selected.");//database name


$message=$_POST['message'];
if(isset($_POST['submit'])) //if submit button push has been detected

{



   if(strlen($message)<1)

   {

      print "You did not input a message";

   }

   else if(strlen($message)>1)

   {

      $message=strip_tags($message);

      $IP=$_SERVER["REMOTE_ADDR"]; //grabs poster's IP

      $checkforbanned="SELECT IP from admin where IP='$IP'";

      $checkforbanned2=mysql_query($checkforbanned) or die("Could not check for banned IPS");

      if(mysql_num_rows($checkforbanned2)>0) //IP is in the banned list

      {

         print "You IP is banned from posting.";

      }

      else
       {

         $message=strip_tags($message);
         echo("<meta http-equiv=\"refresh\" content=\"0; url=registration.php\">");
         echo("<SCRIPT LANGUAGE='JavaScript'>window.alert('$message')</SCRIPT>");
       }

     /*   if($_POST['username'] && $_POST['pass'])
       {

         $name = mysql_query("SELECT * FROM Persons");
         $thedate = date("U"); //grab date and time of the post

         $insertmessage="INSERT into mesej (name,IP,postime,message) values('$name','$IP','$thedate','$message')";

         mysql_query($insertmessage) or die("Could not insert message");

        }     */

   }



}

  else {
   print "<form action='registration.php' method='post' name='form'>";

  print "Your message:<br>";

  print "<textarea name='message' cols='40' rows='2'></textarea><br>";

  print "<a onClick=\"addSmiley('')\"><img src='smile.gif'></a> ";

  print "<a onClick=\"addSmiley('')\"><img src='blush.gif'></a> ";

  print "<a onClick=\"addSmiley('')\"><img src='images/wink.gif'></a> ";

  print "<input type='submit' name='submit' value='Set Name'></form>";

  print "<script language=\"Java Script\" type=\"text/javascript\">\n";

  print "function addSmiley(a)\n";

  print "{\n";

  print "document.form.message.value += a;";

  print "document.form.message.focus();\n";

  print "}\n";

  print "</script>\n";

  print "<br><br>";


  }

?>

 

i had edited the new ones but why the text area name=message im means even it is empty oso it goes through registration.php although it should appear  print "You did not input a message" 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.