logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > General
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-11-2006, 12:21 PM   #1
gregfindley.com
gregfindley.com's Avatar
 
Join Date: Jan 2006
Location: Kent, England
Posts: 191
Default Help Please! PHP Petition..

Hi everyone,

Hoping someone can help me out pretty quick with a few niggling issues I have on a website...

(The site is www.sharkyandgeorge.com, I have integrated phpPETITION scripts into the site)

-The e-mail verification is working, sending out the e-mail, but their signature appears in the petition whether its confirmed or not, how can I change this?

-How to setup the message field so it has a max. no of characters say 150?

-How to change the petition results so it displays 14 or 16 on the first page of results instead of 10?

Thanks for any replies!!
Greg
__________________
www.gregfindley.com
gregfindley.com is offline   Reply With Quote
Old 12-11-2006, 12:53 PM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

what is this PHP petition script

Im asuming that this is a third party class

If so i need to see the code
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 12-11-2006, 12:57 PM   #3
gregfindley.com
gregfindley.com's Avatar
 
Join Date: Jan 2006
Location: Kent, England
Posts: 191
Default

Hi DJ,

Here is the signature.php which is included in the sign the petition page;

<?php
require_once('Connections/petitionscript.php');

mysql_select_db($database_petitionscript, $petitionscript);
$query_rs = "SELECT count(*) as RecordCount FROM signature";
$rs = mysql_query($query_rs, $petitionscript) or die(mysql_error() . " <a href='setup.php'>Click Here</a> to Setup the Table");
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);

mysql_free_result($rs);
?>
<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<form action="received.php" method="post" name="form1" onSubmit="MM_validateForm('FirstName','','R','Last Name','','R','Email','','RisEmail');return document.MM_returnValue">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Name:</td>
<td><input type="text" name="FirstName" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="Email" value="" size="32">
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"><p>Message:</p>
<p>(max. 150 characters)</p></td>
<td><textarea name="Message" rows=5 cols="30"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input name="submit" type="submit" value="SIGN PETITION"></td>
</tr>
</table>
<input type="hidden" name="IP" value="<?php Echo $_SERVER['REMOTE_ADDR'] ?>" size="32">
<input type="hidden" name="Date" value="<?php Echo date('Y-m-d H:i:s') ?>" size="32">
<input type="hidden" name="MM_insert" value="form1">
</form>
__________________
www.gregfindley.com
gregfindley.com is offline   Reply With Quote
Old 12-11-2006, 12:58 PM   #4
gregfindley.com
gregfindley.com's Avatar
 
Join Date: Jan 2006
Location: Kent, England
Posts: 191
Default

Is there a way to set the 'Message' Field to a max of 150 characters firstly?
Thanks! Greg
__________________
www.gregfindley.com
gregfindley.com is offline   Reply With Quote
Old 12-11-2006, 02:50 PM   #5
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

Code:
 
<script type="text/JavaScript">
 
function countText(){
var c0 = 150;
f3 = document.getElementById("Message");
c1 = document.getElementById("counter");
c1.innerHTML =  c0 - f3.value.length;
 if(f3.value.length > 149){
  f3.disabled = true;
 }
}
function formValid() { //v4.0
f1 = document.getElementById("FirstName");
f2 = document.getElementById("Email");
f3 = document.getElementById("Message");
w1 = document.getElementById("warning");
 if(f1 && f2){
 
  if(f3.value.length < 150){
  
   document.forms[0].submit();
  
  }
 
 }else{
 
 w1.innerHTML = "You have an empty field";
 
 }
}
//-->
</script>
<body>
<form action="received.php" method="post" name="form1" onSubmit="formValid()">
<table align="center">
<tr valign="baseline"> 
<td width="133" align="right" nowrap>Name:</td>
<td width="285"><input type="text" name="FirstName" value="" size="32" id="FirstName"></td>
</tr>
<tr valign="baseline"> 
<td nowrap align="right">Email:</td>
<td><input type="text" name="Email" value="" size="32" id="Email"></td>
</tr>
<tr valign="baseline"> 
<td height="114" align="right" valign="top" nowrap><p>Message:</p>
<p>(max. 150 characters)</p></td>
<td><p>
  <textarea name="Message" rows=5 cols="30"  id="Message"  onKeyDown="countText()"></textarea>
  <br>
  
 Remaining Chars <div id="counter"></div>
  
</p>
  </td>
</tr>
<tr valign="baseline"> 
<td nowrap align="right">&nbsp;</td>
<td><input name="submit" type="submit" value="SIGN PETITION"></td>
</tr>
<tr valign="baseline">
  <td height="44" colspan="2" align="center" valign="middle" nowrap>
  
  <div id="warning"></div>
  
  </td>
  </tr>
</table>
<input type="hidden" name="IP" value="<?php Echo $_SERVER['REMOTE_ADDR'] ?>" size="32">
<input type="hidden" name="Date" value="<?php Echo date('Y-m-d H:i:s') ?>" size="32">
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 12-11-2006, 03:18 PM   #6
gregfindley.com
gregfindley.com's Avatar
 
Join Date: Jan 2006
Location: Kent, England
Posts: 191
Default

Thanks for that DJ!

The only thing is it locks up the text box if you go over 100 characters (reduced it from 150 to 100) and then you can't edit it without refreshing the page. Is there anyway to make it so you can still edit, but not submit if that makes sense?

Thanks for your help!
Really appreciated

Greg
__________________
www.gregfindley.com
gregfindley.com is offline   Reply With Quote
Old 12-11-2006, 03:49 PM   #7
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

replace

Code:
f3.disabled = true;
with

Code:
 
f3.value = f3.value.substring(1, c0);
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 12-11-2006, 03:57 PM   #8
gregfindley.com
gregfindley.com's Avatar
 
Join Date: Jan 2006
Location: Kent, England
Posts: 191
Default

Thats great thanks DJ!!

Can you help me setup the petition results page so it displays 14 results instead of 10 per page?

<?php require_once('Connections/petitionscript.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];

$maxRows_rsResult = 10;
$pageNum_rsResult = 0;
if (isset($_GET['pageNum_rsResult'])) {
$pageNum_rsResult = $_GET['pageNum_rsResult'];
}
$startRow_rsResult = $pageNum_rsResult * $maxRows_rsResult;

mysql_select_db($database_petitionscript, $petitionscript);
$query_rsResult = "SELECT * FROM signature";
$query_limit_rsResult = sprintf("%s LIMIT %d, %d", $query_rsResult, $startRow_rsResult, $maxRows_rsResult);
$rsResult = mysql_query($query_limit_rsResult, $petitionscript) or die(mysql_error());
$row_rsResult = mysql_fetch_assoc($rsResult);

if (isset($_GET['totalRows_rsResult'])) {
$totalRows_rsResult = $_GET['totalRows_rsResult'];
} else {
$all_rsResult = mysql_query($query_rsResult);
$totalRows_rsResult = mysql_num_rows($all_rsResult);
}
$totalPages_rsResult = ceil($totalRows_rsResult/$maxRows_rsResult)-1;

$queryString_rsResult = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rsResult") == false &&
stristr($param, "totalRows_rsResult") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rsResult = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rsResult = sprintf("&totalRows_rsResult=%d%s", $totalRows_rsResult, $queryString_rsResult);
?><html>




<title>SharkyandGeorge.com - Petition for the crimebusters of the sea</title>
<meta http-equiv="content-type" content=
"text/html; charset=utf-8" />

<script language="javascript">
//--------------- LOCALIZEABLE GLOBALS ---------------
var d=new Date();
var monthname=new Array("January","February","March","April","May"," June","July","August","September","October","Novem ber","December");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
//--------------- END LOCALIZEABLE ---------------
</script>

<meta name="description" content="Sharky and George.com the online petition for the crimebusters of the sea" />
<meta name="keywords" content="sharky and george, sharky, george, sharky n george, sharkey and george, sharky and georges, crimebusters of the sea, crimebusters, sharkyandgeorge" />
<meta name="author" content="SharkyandGeorge.com" />
<meta name="copyright" content="SharkyandGeorge.com" />
<meta name="company" content="SharkyandGeorge.com" />
<meta name="revisit-after" content="3 days" />
<link rel="shortcut icon" href="/favicon.ico" type=
"image/x-icon" />
<link rel="stylesheet" href="sitestyle.css" type="text/css" media=
"screen" />
<link rel="stylesheet" href="thickbox.css" type="text/css" media=
"screen" />
<style type="text/css" media="all"></style>
<style type="text/css" media="all"></style>
<script language="JavaScript" type="text/JavaScript">
<!--



function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
<script type="text/javascript">
function bookmark(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
</script>
</head>
<body>
<center>

<div id="header">
</div>


<div id="content">



<div id="horizontal">
<div id="horizontaltext"> <a href="http://www.sharkyandgeorge.com/index.html">Welcome</a>
| <a href="http://www.sharkyandgeorge.com/petition/index.php">Sign the
Petition</a> | <a href="http://www.sharkyandgeorge.com/petition/results.php">View
the Petition</a> | <a href="http://www.sharkyandgeorge.com/gallery.html">Gallery
</a>| <a href="javascript:bookmark('SharkyandGeorge.com - Petition for the crimebusters of the sea', 'http://www.sharkyandgeorge.com')" ('bookmark','','images/bookmark_on.gif',1)">Bookmark us</a>
| <a href="http://www.sharkyandgeorge.com/banners.html">Get a Banner</a>
| <a href="http://www.sharkyandgeorge.com/links.html">Links</a></div>
</div>

<script type="text/javascript"><!--
google_ad_client = "pub-3181967717440575";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel = "";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "0066CC";
google_color_text = "000000";
google_color_url = "3D81EE";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>




<div id="maincontent">



<table width="675" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FFFFFF"><p><font color="#0066CC"><img src="phpPetitionTemplate/mm_spacer.gif" alt="" width="1" height="1" border="0">&nbsp;
<br>
<b>
<?php echo "So far we have " . $totalRows_rsResult . " signatures" ?>
</b> </font></p>
<table width="675" border="0" cellpadding="5">
<tr align="center" valign="middle" bgcolor="#3165CE">
<?php
if ((isset($_GET['ADMIN'])) && ($_GET['ADMIN'] != ""))
echo '<td><span class="style1">Delete</span></td>';
?>
<td width="176"><font color="#FFFFFF" size="-1" face="Verdana, Arial, Helvetica, sans-serif"><span class="style1">Name</span></font></td>
<td width="359"><font color="#FFFFFF" size="-1" face="Verdana, Arial, Helvetica, sans-serif"><span class="style1">Message</span></font></td>
<td width="102"><font color="#FFFFFF" size="-1" face="Verdana, Arial, Helvetica, sans-serif"><span class="style1">Date
</span></font><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"><span class="style1"><font color="#FFFFFF"><br>
</font> </span></font></td>
</tr>
<?php //$row = 0+$startRow_rsResult ?>
<?php do { ?>
<?php //$row == $row++ ?>
<tr>
<?php
if ((isset($_GET['ADMIN'])) && ($_GET['ADMIN'] = "On"))
echo '<td><a href=Delete2.php?ID='.$row_rsResult['ID'].'>Delete<a></td>';
?>
<td><font color="#000000" size="-1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_rsResult['FirstName']; ?></font></td>
<td><font color="#000000" size="-1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_rsResult['Message']; ?></font></td>
<td align="center"><font color="#000000" size="-1" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_rsResult['TSDate']; ?> </font></td>
</tr>
<?php } while ($row_rsResult = mysql_fetch_assoc($rsResult)); ?>
</table>
<p>&nbsp;</p>
<table border="0" width="30%" align="center">
<tr>
<td width="23%" align="center"><font color="#0000FF">
<?php if ($pageNum_rsResult > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_rsResult=%d%s", $currentPage, 0, $queryString_rsResult); ?>"><img src="Admin/Images/Begining.gif" alt="Goto First Signature" width="21" height="21" border=0></a>
<?php } // Show if not first page ?>
</font></td>
<td width="31%" align="center"><font color="#0000FF">
<?php if ($pageNum_rsResult > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_rsResult=%d%s", $currentPage, max(0, $pageNum_rsResult - 1), $queryString_rsResult); ?>"><img src="Admin/Images/backward.gif" alt="Previous Page" width="20" height="20" border=0></a>
<?php } // Show if not first page ?>
</font></td>
<td width="23%" align="center"><font color="#0000FF">
<?php if ($pageNum_rsResult < $totalPages_rsResult) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_rsResult=%d%s", $currentPage, min($totalPages_rsResult, $pageNum_rsResult + 1), $queryString_rsResult); ?>"><img src="Admin/Images/Forward.gif" alt="Next Page" width="21" height="20" border=0></a>
<?php } // Show if not last page ?>
</font></td>
<td width="23%" align="center"><font color="#0000FF">
<?php if ($pageNum_rsResult < $totalPages_rsResult) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_rsResult=%d%s", $currentPage, $totalPages_rsResult, $queryString_rsResult); ?>"><img src="Admin/Images/End.gif" alt="Goto Last Signature" width="22" height="21" border=0></a>
<?php } // Show if not last page ?>
</font></td>
</tr>
</table> </td>
</tr>
</table>




</body>
</html>
<?php
mysql_free_result($rsResult);
?>

</div>



</div>


<div id="footer"></div>


</center>
</body>
</html>
__________________
www.gregfindley.com
gregfindley.com is offline   Reply With Quote
Old 12-11-2006, 03:59 PM   #9
gregfindley.com
gregfindley.com's Avatar
 
Join Date: Jan 2006
Location: Kent, England
Posts: 191
Default

I tried changing this "$maxRows_rsResult = 10;" to 14 but nothing changed still displayed 10?

Thanks,
Greg
__________________
www.gregfindley.com
gregfindley.com is offline   Reply With Quote
Old 12-11-2006, 03:59 PM   #10
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

replace
Code:
$maxRows_rsResult = 10;
with
Code:
$maxRows_rsResult = 14;
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:35 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com