Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> For Hire
Author Message
rebelt
Worker
Worker



Joined: May 07, 2006
Posts: 172

PostPosted: Thu May 17, 2012 8:14 am Reply with quote

I have a number of forms I would like turned into modules.

Did look at trying this myself, but couldn't even get topolino to work. Rolling Eyes

Basically public would be add and view, with admin able to edit and delete.

Files and tables are Only registered users can see links on this board! Get registered or login!

List of forms can be viewed Only registered users can see links on this board! Get registered or login!

Please PM if interested

_________________
I wish I knew what I was doing LOL 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Fri May 25, 2012 12:08 am Reply with quote

Are you still needing this?
 
View user's profile Send private message
rebelt







PostPosted: Fri May 25, 2012 10:18 am Reply with quote

Yes please.

I did try and make a start with the 8 ball module, but I have no blocks left or right.

Here's what I have as index.php
Code:
<?php

if (!defined('MODULE_FILE')) {
   die ("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
define('INDEX_FILE', true);
include("header.php");

OpenTable();
global $db;


$result = $db->sql_query("SELECT * FROM team_8_balls ORDER BY player");

if ($myrow = $db->sql_fetchrow($result)) {


echo "<center><B>All 8 balls submitted using the correct form will now be displayed.</b><BR></center>";

  echo "<BR><center><table width=75% border=1 valign=top>";

  echo "<tr><td bgcolor=\"#B1CFED\"><center><b>Player</b></center></td><td bgcolor=\"#B1CFED\"><center><b>Team</b></center></td><td bgcolor=\"#B1CFED\"><center><b>Date</b></center></td></tr>\n";

  do {

    printf("<tr><td bgcolor=\"#EEF4FC\"><center>%s</center></td><td bgcolor=\"#EEF4FC\"><center>%s</center></td><td bgcolor=\"#EEF4FC\"><center>%s</center></tr>\n", $myrow["player"], $myrow["team"], $myrow["match_date"]);

  } while ($myrow = $db->sql_fetchrow($result));

   echo "</table>\n";

} else {

   echo "<center><B>If you're seeing this, no one has achieved an 8 ball break for the new season yet.</b></center>";   

}

CloseTable();
OpenTable();
echo"<FORM ACTION=\"http://sitename.org.uk/forms/index_8ball.php\" method=\"post\">"
  . "<p align=\"center\"><img src=\"images/8break_e0.gif\" width=\"128\" height=\"128\" /></p>"
  . "<p align=\"center\"><b><font color=\"#6600FF\" face=\"verdana,arial,helvetica\" size=\"4\">Break and Dish</font></b></p>"
  . ""
  . "<p align=\"center\"><font color=\"#000000\" face=\"verdana,arial,helvetica\" size=\"2\">Fill out the following"
  . "information (bold fields are mandatory) and click 'Submit'.</font></p>"
  . "<div align=\"center\">"
  . "  <table border=\"0\" cellspacing=\"0\" cellpadding=\"2\">"
  . "    <tr>"
  . "      <td align=right valign=top nowrap><font face=\"Verdana\" size=\"2\" color=\"#000000\" ><b>Date of Match:</b></font></td>"
  . "      <td nowrap><font size=\"2\" face=\"Verdana\">"
  . "        <input name=\"DateOfMatch\" size=\"30\">"
  . "        </font></td>"
  . "    </tr><tr>"
  . "        <td align=right valign=top nowrap><font face=\"Verdana\" size=\"2\" color=\"#000000\" ><b>Division:</b></font></td>"
  . "        <td nowrap><font size=\"2\" face=\"Verdana\">"
  . "          <input name=\"Division\" size=\"30\">"
  . "        </font></td>"
  . "        </tr><tr>"
  . "          <td align=right valign=top nowrap><font face=\"Verdana\" size=\"2\" color=\"#000000\" ><b>Team:</b></font></td>"
  . "          <td nowrap><font size=\"2\" face=\"Verdana\">"
  . "          <input name=\"Team\" size=\"30\">"
  . "          </font></td>"
  . "          </tr><tr>"
  . "            <td align=right valign=top nowrap><font face=\"Verdana\" size=\"2\" color=\"#000000\" ><b>Player:</b></font></td>"
  . "            <td nowrap><font size=\"2\" face=\"Verdana\">"
  . "            <input name=\"Player\" size=\"30\">"
  . "            </font></td>"
  . "            </tr><tr>"
  . "              <td align=right valign=top nowrap><font face=\"Verdana\" size=\"2\" color=\"#000000\" ><b>Submitted By:</b></font></td>"
  . "              <td nowrap><font size=\"2\" face=\"Verdana\">"
  . "              <input name=\"Submitted_By\" size=\"30\">"
  . "              </font></td>"
  . "              </tr><tr>"
  . "                <td align=right valign=top nowrap><font face=\"Verdana\" size=\"2\" color=\"#000000\" ><b>Email Address:</b></font></td>"
  . "                <td nowrap><font size=\"2\" face=\"Verdana\">"
  . "                <input name=\"Email\" size=\"30\">"
  . "                </font></td>"
  . "                </tr>"
  . "    <tr>"
  . "      <td nowrap colspan=\"2\"></td>"
  . "      </tr>"
  . "    <tr>"
  . "      <td nowrap colspan=\"2\" align=\"center\">"
  . "        <div align=\"center\">"
  . ""
  . "          <center>"
  . "            <p><br><font face=\"Verdana\" size=\"2\"><input name=\"B1\" type=\"submit\" value=\"     Submit     \">&nbsp; <input name=\"B2\" type=\"reset\" value=\"     Reset     \"></font></p>"
  . "            </center>"
  . "          </div>"
  . "        </td>"
  . "      </tr>"
  . "  </table>"
  . "</div>"
  . "<font face=\"Verdana\" size=\"2\">"
  . ""
  . "</FORM>";
  @$ip= $_SERVER['REMOTE_ADDR'];
@$DateOfMatch = addslashes($_POST['DateOfMatch']);
@$Division = addslashes($_POST['Division']);
@$Team = addslashes($_POST['Team']);
@$Player = addslashes($_POST['Player']);
@$Submitted_By = addslashes($_POST['Submitted_By']);
@$Email = addslashes($_POST['Email']);

// Validation
if (strlen($DateOfMatch) !=8)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid date.</font></p>");
}

if (strlen($DateOfMatch) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid date.</font></p>");
}

if (strlen($Division) >=12)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid division</font></p>");
}

if (strlen($Division) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid division</font></p>");
}

if (strlen($Team) >=21)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid team name</font></p>");
}

if (strlen($Player) == 0 )
{
die("");
}

if (strlen($Submitted_By) == 0 )
{
die("");
}

if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email))
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}

if (strlen($Email) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid email</font></p>");
}

//Sending Email to form owner
$header = "From: $Email\n"
  . "Reply-To: $Email\n";
$subject = "8 Ball";
$email_to = "webmaster@westonpoolleague.org.uk";
$message = "Visitor's IP: $ip\n"
. "DateOfMatch: $DateOfMatch\n"
. "Division: $Division\n"
. "Team: $Team\n"
. "Player: $Player\n"
. "Submitted_By: $Submitted_By\n"
. "Email: $Email\n";
@mail($email_to, $subject ,$message ,$header ) ;

//Sending auto respond Email to visitor
$header = "From: noreply@westonpoolleague.org.uk\n"
  . "Reply-To: noreply@westonpoolleague.org.uk\n";
$subject = "8 Ball submitted";
$email_to = "$Email";
$message = "Thanks for submitting the following info\n"
. "DateOfMatch: $DateOfMatch\n"
. "Division: $Division\n"
. "Team: $Team\n"
. "Player: $Player";
@mail($email_to, $subject ,$message ,$header ) ;

//saving record in a text file
$file_name = "8balls.csv";
$first_raw = "DateOfMatch,Division,Team,Player,Submitted_By,Email\r\n";
$values = "$DateOfMatch,$Division,$Team,$Player,$Submitted_By,$Email\r\n";
$is_first_row = false;
if(!file_exists($file_name))
{
 $is_first_row = true ;
}
if (!$handle = fopen($file_name, 'a+')) {
 die("Cannot open file ($file_name)");
 exit;
}
if ($is_first_row)
{
  if (fwrite($handle, $first_raw ) === FALSE) {
  die("Cannot write to file ($filename)");
  exit;
  }
}
if (fwrite($handle, $values) === FALSE) {
  die("Cannot write to file ($filename)");
  exit;
}
fclose($handle);

//saving record to MySQL database
//changing date formats


@$query = "INSERT INTO `team_8_balls`(`match_date`,`division`,`team`,`player`,`submitted_by`,`email`)VALUES (\"$DateOfMatch\",\"$Division\",\"$Team\",\"$Player\",\"$Submitted_By\",\"$Email\")" ;


//insert new record
$result = mysql_query($strQuery);
if (!$result) {
 die('Invalid query: ' . mysql_error());
}

 echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Thank you for submitting the information.  You should receive a confirmation email shortly.</font></p>");

CloseTable();
include("footer.php");

?>


Not even attempted the admin part yet.
 
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1775

PostPosted: Fri May 25, 2012 11:46 am Reply with quote

...validated to 0 errors.
if you use "die", then stop the script at this point. that was it, why don't you see the blocks. the footer was not loaded.

check this very helpful plugins for firefox and you will found your errors in the html-code:
http://users.skynet.be/mgueury/mozilla/
http://getfirebug.com/

Code:
<?php

if (!defined('MODULE_FILE')) {
   die ("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
define('INDEX_FILE', true);
include_once("header.php");

OpenTable();
global $db;


$result = $db->sql_query('SELECT * FROM team_8_balls ORDER BY player');

if ($myrow = $db->sql_fetchrow($result)) {


echo '<center><b>All 8 balls submitted using the correct form will now be displayed.</b><br /></center>'."\n";

  echo '<br /><center><table width="75%" border="1" valign="top">'."\n";

  echo '<tr><td bgcolor="#B1CFED"><center><b>Player</b></center></td><td bgcolor="#B1CFED"><center><b>Team</b></center></td><td bgcolor="#B1CFED"><center><b>Date</b></center></td></tr>'."\n";

  do {

    printf('<tr><td bgcolor="#EEF4FC"><center>%s</center></td><td bgcolor="#EEF4FC"><center>%s</center></td><td bgcolor="#EEF4FC"><center>%s</center></tr>'."\n", $myrow['player'], $myrow['team'], $myrow['match_date']);

  } while ($myrow = $db->sql_fetchrow($result));

   echo '</table>'."\n";

} else {

   echo '<center><b>If you\'re seeing this, no one has achieved an 8 ball break for the new season yet.</b></center>'."\n";   

}

CloseTable();
OpenTable();
echo'<form action="http://sitename.org.uk/forms/index_8ball.php" method="post">'."\n"
  . '<p align="center"><img src="images/8break_e0.gif" width="128" height="128" alt="" /></p>'."\n"
  . '<p align="center"><b><font color="#6600FF" face="verdana,arial,helvetica" size="4">Break and Dish</font></b></p>'."\n"

  . '<p align="center"><font color="#000000" face="verdana,arial,helvetica" size="2">Fill out the following'."\n"
  . 'information (bold fields are mandatory) and click \'Submit\'.</font></p>'."\n"
  . '<div align="center">'."\n"
  . '   <table border="0" cellspacing="0" cellpadding="2">'."\n"
  . '      <tr>'."\n"
  . '      <td align="right" valign="top" style="white-space:nowrap"><font face="Verdana" size="2" color="#000000" ><b>Date of Match:</b></font></td>'."\n"
  . '      <td style="white-space:nowrap"><font size="2" face="Verdana">'."\n"
  . '      <input name="DateOfMatch" size="30" />'."\n"
  . '      </font></td>'."\n"
  . '    </tr>'."\n"
  . '    <tr>'."\n"
  . '      <td align="right" valign="top" style="white-space:nowrap"><font face="Verdana" size="2" color="#000000" ><b>Division:</b></font></td>'."\n"
  . '      <td style="white-space:nowrap"><font size="2" face="Verdana">'."\n"
  . '      <input name="Division" size="30" />'."\n"
  . '      </font></td>'."\n"
  . '    </tr>'."\n"
  . '    <tr>'."\n"
  . '      <td align="right" valign="top" style="white-space:nowrap"><font face="Verdana" size="2" color="#000000" ><b>Team:</b></font></td>'."\n"
  . '      <td style="white-space:nowrap"><font size="2" face="Verdana">'."\n"
  . '      <input name="Team" size="30" />'."\n"
  . '      </font></td>'."\n"
  . '    </tr>'."\n"
  . '    <tr>'."\n"
  . '      <td align="right" valign="top" style="white-space:nowrap"><font face="Verdana" size="2" color="#000000" ><b>Player:</b></font></td>'."\n"
  . '      <td style="white-space:nowrap"><font size="2" face="Verdana">'."\n"
  . '      <input name="Player" size="30" />'."\n"
  . '      </font></td>'."\n"
  . '    </tr>'."\n"
  . '    <tr>'."\n"
  . '      <td align="right" valign="top" style="white-space:nowrap"><font face="Verdana" size="2" color="#000000" ><b>Submitted By:</b></font></td>'."\n"
  . '      <td style="white-space:nowrap"><font size="2" face="Verdana">'."\n"
  . '      <input name="Submitted_By" size="30" />'."\n"
  . '      </font></td>'."\n"
  . '    </tr>'."\n"
  . '    <tr>'."\n"
  . '      <td align="right" valign="top" style="white-space:nowrap"><font face="Verdana" size="2" color="#000000" ><b>Email Address:</b></font></td>'."\n"
  . '      <td style="white-space:nowrap"><font size="2" face="Verdana">'."\n"
  . '      <input name="Email" size="30" />'."\n"
  . '      </font></td>'."\n"
  . '    </tr>'."\n"
  . '    <tr>'."\n"
  . '      <td style="white-space:nowrap" colspan="2"></td>'."\n"
  . '    </tr>'."\n"
  . '    <tr>'."\n"
  . '      <td style="white-space:nowrap" colspan="2" align="center">'."\n"
  . '         <div align="center">'."\n"
  . '            <center>'."\n"
  . '            <p><br /><font face="Verdana" size="2"><input name="B1" type="submit" value="     Submit     " />&nbsp; <input name="B2" type="reset" value="     Reset     " /></font></p>'."\n"
  . '            </center>'."\n"
  . '         </div>'."\n"
  . '      </td>'."\n"
  . '    </tr>'."\n"
  . '  </table>'."\n"
  . '</div>'."\n"
  . '</form>'."\n";
 
//  . '<font face="Verdana" size="2">'."\n";

  @$ip= $_SERVER['REMOTE_ADDR'];
  @$DateOfMatch = addslashes($_POST['DateOfMatch']);
  @$Division = addslashes($_POST['Division']);
  @$Team = addslashes($_POST['Team']);
  @$Player = addslashes($_POST['Player']);
  @$Submitted_By = addslashes($_POST['Submitted_By']);
  @$Email = addslashes($_POST['Email']);

// Validation
if (strlen($DateOfMatch) !=8) {
   echo '<p align="center"><font face="Arial" size="3" color="#FF0000">Please enter a valid date.</font></p>'."\n";
}

if (strlen($DateOfMatch) == 0 ) {
   echo '<p align="center"><font face="Arial" size="3" color="#FF0000">Please enter a valid date.</font></p>'."\n";
}

if (strlen($Division) >=12) {
   echo '<p align="center"><font face="Arial" size="3" color="#FF0000">Please enter a valid division</font></p>'."\n";
}

if (strlen($Division) == 0 ) {
   echo '<p align="center"><font face="Arial" size="3" color="#FF0000">Please enter a valid division</font></p>'."\n";
}

if (strlen($Team) >=21) {
   echo '<p align="center"><font face="Arial" size="3" color="#FF0000">Please enter a valid team name</font></p>'."\n";
}

if (strlen($Player) == 0 ) {
   echo '';
}

if (strlen($Submitted_By) == 0 ) {
   echo '';
}

if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email)) {
   echo '<p align="center"><font face="Arial" size="3" color="#FF0000">Please enter a valid email</font></p>'."\n";
}

if (strlen($Email) == 0 ) {
   echo '<p align="center"><font face="Arial" size="3" color="#FF0000">Please enter a valid email</font></p>'."\n";
}

//Sending Email to form owner
$header = "From: $Email\n"
  . "Reply-To: $Email\n";
$subject = "8 Ball";
$email_to = "webmaster@westonpoolleague.org.uk";
$message = "Visitor's IP: $ip\n"
. "DateOfMatch: $DateOfMatch\n"
. "Division: $Division\n"
. "Team: $Team\n"
. "Player: $Player\n"
. "Submitted_By: $Submitted_By\n"
. "Email: $Email\n";
@mail($email_to, $subject ,$message ,$header ) ;

//Sending auto respond Email to visitor
$header = "From: noreply@westonpoolleague.org.uk\n"
  . "Reply-To: noreply@westonpoolleague.org.uk\n";
$subject = "8 Ball submitted";
$email_to = "$Email";
$message = "Thanks for submitting the following info\n"
. "DateOfMatch: $DateOfMatch\n"
. "Division: $Division\n"
. "Team: $Team\n"
. "Player: $Player";
@mail($email_to, $subject ,$message ,$header ) ;

//saving record in a text file
$file_name = "8balls.csv";
$first_raw = "DateOfMatch,Division,Team,Player,Submitted_By,Email\r\n";
$values = "$DateOfMatch,$Division,$Team,$Player,$Submitted_By,$Email\r\n";
$is_first_row = false;
if(!file_exists($file_name)) {
   $is_first_row = true;
}
if (!$handle = fopen($file_name, 'a+')) {
   echo 'Cannot write to file (' . $filename . ')';
   exit;
}
if ($is_first_row) {
  if (fwrite($handle, $first_raw ) === FALSE) {
   echo 'Cannot write to file (' .$filename . ')';
   exit;
  }
}
if (fwrite($handle, $values) === FALSE) {
   echo 'Cannot write to file (' .$filename . ')';
  exit;
}
fclose($handle);

//saving record to MySQL database
//changing date formats


@$query = 'INSERT INTO `team_8_balls`(`match_date`,`division`,`team`,`player`,`submitted_by`,`email`)VALUES ("$DateOfMatch","$Division","$Team","$Player","$Submitted_By","$Email")';


//insert new record
$result = mysql_query($strQuery);
if (!$result) {
 echo 'Invalid query: ' . mysql_error();
}

 echo '<p align="center"><font face="Arial" size="3" color="#FF0000">Thank you for submitting the information.  You should receive a confirmation email shortly.</font></p>'."\n";

CloseTable();
include_once 'footer.php';
?>
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> For Hire

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©