PDA

View Full Version : Searching for PHP genius with some time left



Peppy
03-09-2005, 04:46 PM
I found a code that I tried to modify - now it does not work anymore for I made many faults.

I'd like someone to have a look at it and help me to get my page to work!

THANKS in advance!

mwinter
03-10-2005, 02:21 PM
I found a code that I tried to modify - now it does not work anymore for I made many faults.

I'd like someone to have a look at it and help me to get my page to work!There may be many people capable of helping. Post the code or preferably a link to it.

Files associated with the application/x-httpd-php-source MIME type (typically a .phps extension) should be shown as syntax-highlighted source code. If your server isn't configured to do that, just serve a plain text (.txt) file.

Mike

Peppy
03-10-2005, 08:28 PM
Mike - I'm glad you're here!

Please help me at first with this prase error:

Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /usr/export/www/vhosts/funnetwork/hosting/deancainwwfl/state or region.php on line 56

This is line 56:
echo "<td><a href="$url\">www</a></td>"; }

Peppy
03-10-2005, 08:37 PM
Second:


<table border="0" cellspacing="0" cellpadding="2" width="90%">
<tr></tr><td width="30%">Name:</td>
<td><INPUT TYPE="text" NAME="name" SIZE="40" class="form"></td></tr>


<tr>
<td colspan="2">
<table>
<tr>
<td>sex:</td>
<td><input type="radio" name="sex" value="m" class="formular" />
male</td>
<td><input type="radio" name="sex" value="w" class="formular" />
female</td>
</tr>
</table>
</td>
</tr>


The first code is for the name column in the join.php

http://deancainwwfl.de.funpic.de/join.php (to see what I mean)

I added the second code - two buttons male, female - but I want them more to the right - how can I change the position?

mwinter
03-10-2005, 10:54 PM
This is line 56:
echo "<td><a href="$url\">www</a></td>"; }You haven't escaped the second double quote; the one just before the variable.


I added the second code - two buttons male, female - but I want them more to the left - how can I change the position?Further left so that the "Sex" label is aligned with the rest? You'll need to adjust the margins and padding of both the nested table and its cells using CSS.

If you gave the nested table an id, the CSS would be along the lines of


#table-id,
#table-id * {
margin: 0;
padding: 0;
}

#table-id td {
margin-right: ??;
}where ?? denotes the space between the three cells. Of course, you can use other selectors to alter specific parts within the nested table. An alternative solution would be to change how you lay out the form, but you're probably not interesting in doing something so drastic to change something so simple.

A few comments on the content as it stands...

If you're going to break down the UK/ROI archipelago, you should certainly include Northern Ireland, though I'd leave it at the "United Kingdom" and the "Republic of Ireland". Someone could always use the next control to be more specific if they felt like it. You could also include the Isle of Man and the Channel Islands as, whilst they are represented internationally by the UK Government and are part of the Commonwealth, they are largely autonomous and are not strictly part of the UK.

I think "Postal code" is a better label than "Zip code". It's more international.

Using client-side scripting to write in e-mail addresses is not a safe way to protect those addresses from spam bots. Modern spam bots are capable of interpreting ECMAScript and even if one can't do it directly, there's no reason why it can't run off a browser engine that can. The only way to protect e-mail addresses is to not expose them at all. A system used on some forum software (but not this one) is better where the e-mail is sent internally using a form processing script. Only the sender would have their address exposed, and then only to the recipient of the mail, unless the recipient responds of course.

"Don't" is a bad name for the reset button. If I clicked on that, I'd expect to be routed away from the form.


function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){This doesn't detect IE or Netscape, nor is it necessary.


if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")The type property will always contain a lowercase string. I also fail to see why you need to disable the reset button.

In general, it's a bad idea to disable controls in this manner. If there is a problem with transmission, using the Back button will take a user to a page which can no longer be submitted. A better solution would be to compare the submitted e-mail address to a list of previously entered values. This list could be complete, or just addresses found within a certain period. If the address is a duplicate, either warn the user and ask if they want to update the information previously provided (which could be tricky and require the introduction of passwords) or discard the submission.

If you do want to keep the disabling code,


function submitOnce(form) {
var e = form.elements,
i = e.length,
c;

while(i--) {
c = e[i];
if('submit' == c.type) {c.disabled = true;}
}
}is sufficient. You could break the loop upon discovering the submit button or leave it going. You could also disable the reset button if you want (which means the loop couldn't be broken early). Your choice.

Hope that helps,
Mike

Peppy
03-11-2005, 10:19 AM
Good morning Mike! :)

Thank you so much!!!!!!!!!! You made my day!

* I changed the '\' thing. Thx.

* Concerning the button position:
It was late last night - I ment more to the right (not to the left) !!
I now got a part of a solution - look here: http://deancainwwfl.de.funpic.de/join.php

This is the code:


<tr>
<td>&nbsp;</td>
<td>
<table>
<tr>
<td>sex:</td>
<td><input type="radio" name="sex" value="m" class="formular"
/> male</td>
<td><input type="radio" name="sex" value="w" class="formular"
/> female</td>
</tr>
</table>
</td>
</tr>

But I don't want the word "sex" to change it's possition - only the two buttons!

* I appreciate your comments!

Since I don't know as much as you about the UK I' d like to ask you:
Would you be so kind to do all the changes in the join.txt and send it to me?
It sounds like you knwo very well what you are talking about and I would like to have a perfekt listing ...
I sent you a private message - there you find links to all the codes as txt files and as php.

I changed zip code into postal code , in the MySQL table, too - I hope I didn't forget one - anywhere else.

Reset is better than Don't! I changed it!


the e-mail is sent internally using a form processing script. Only the sender would have their address exposed, and then only to the recipient of the mail, unless the recipient responds of course.

That would be great! But I don't know how to do it! If you could do it using the above mentioned txt.files - please !!! Maybe that way - the member can choose to show his e-mail or to use the form processing script!

The other things you mentioned - I' m sorry - I don't have a clue what you are talking about - remember - it was'nt me who wrote the script - unfortunatley I can't do it! :rolleyes:

Please help me to solve all the other things first and than we can come back to those suggestions.

Again - thank you!

mwinter
03-11-2005, 01:12 PM
Good morning Mike! :)Afternoon. :D


Thank you so muchHold your thanks for when it's all finished, OK? There's a way to go yet to do all the things you asked in private. It may also take some time - I'm fiddling with code I've never looked at before.


* I changed the '\' thing. Thx.Poking around, I found a similar problem when members.php is viewed. Lines 62,


echo "<td><a href="$url\">www</a></td>"; }and 93,


echo "<td><a href="country.php?id=$country\">$country</a></td>";also have unescaped, nested double quotes. There might be other affected files. I haven't looked through them all yet.


But I don't want the word "sex" to change it's possition - only the two buttons!Then presumably "Sex:" should replace &nbsp; in the first cell (it shouldn't be in the nested table), and the rest of the nested table should be in the second cell.


Would you be so kind to do all the changes in the join.txt and send it to me?Sure. As I might end up fiddling with lots of things, I could either send everything all at once, or as I finish. It's up to you.


It sounds like you knwo very well what you are talking about and I would like to have a perfekt listing ...Not as such. I know that the two groups of islands are technically separate from the rest of the UK, but as I don't know anyone from either, I couldn't say whether residents prefer to be separate, or if they're content with saying they live in the UK.


[Regarding hiding e-mails:] That would be great! But I don't know how to do it! If you could do it using the above mentioned txt.files - please !!! Maybe that way - the member can choose to show his e-mail or to use the form processing script!I should be able to, but it depends if your host allows scripts to use the mail() function in PHP. When people join your fan list, do you receive notification e-mails? If yes, then it should be possible.


The other things you mentionedThe client-side submitOnce stuff?


I' m sorry - I don't have a clue what you are talking aboutThat's fine. I could always include it for you.


Please help me to solve all the other things first and than we can come back to those suggestions.Alright. Again, I can't promise when I'll finish. It could be tomorrow. It could be the end of next week. It depends how much time I get to spend on it, OK?

A final question: is this live yet? Do you have a database full of members, or are you just setting up at the moment? I'm somewhat confused about the links to the other fan list you gave me.

Mike

Peppy
03-11-2005, 03:03 PM
A final question: is this live yet? Do you have a database full of members, or are you just setting up at the moment? I'm somewhat confused about the links to the other fan list you gave me.No it's not live yet - unfortunatley!
The other fan list is running since 2004, I think, but it doesn't fulfil my needs.
I want the member-counting not only per country but also per state or region and city.


[Regarding hiding e-mails:] I should be able to, but it depends if your host allows scripts to use the mail() function in PHP. When people join your fan list, do you receive notification e-mails? If yes, then it should be possible.I think I do - yes, I once made a test and received an email.


I couldn't say whether residents prefer to be separate, or if they're content with saying they live in the UK.Ok - let's wait until someone complains.

* I changed all the other '\' things I was able to find.


Then presumably "Sex:" should replace &nbsp; in the first cell (it shouldn't be in the nested table), and the rest of the nested table should be in the second cell.I did it - now it looks quite good - but the to buttons are not exactly under the other fields, why?

<tr>
<td>sex:</td>
<td>
<table border="0">
<tr>
<td><input type="radio" name="sex" value="m" class="formular"/> male</td>
<td><input type="radio" name="sex" value="w" class="formular" /> female</td>
</tr>
</table>
</td>
</tr> [/CODE]
http://deancainwwfl.de.funpic.de/join.php



Alright. Again, I can't promise when I'll finish. It could be tomorrow. It could be the end of next week. It depends how much time I get to spend on it, OK?Thank you anyway - if you just help me - step by step I will have a wonderful page - that works, too!

Just to remind you. The first thing should be the code to manage the counting of the fans per country, per state or region and per city and a list with the members url or @ - in case they added it! This is the hardest part I guess. I don't knwo if it is possible at all.

Peppy
03-12-2005, 05:05 PM
Which part of the original code effects that when you click on a country the members of this country are listed?

Maybe we could use this part to make the regions (not the members) show up when you click on a country, by changing the variables (?) - instead of members => state or region.
The same procedure to make the cities show up when you click on state or region. (instead of country and member => state and region and city.


There is another code that effects that all members sorted by country are listed.
Maybe we could use this code to list all members of a city - (not of a country) by only changing the words members by country => into mebers by city!?

*thinking loud*

Peppy
03-12-2005, 10:21 PM
I will also have to change the config.php

Original:
//How would you like to have the members sorted on the All and Country pages?
$allsort ="country"; // choose either id, name or country
$countrysort ="name"; //choose either id or name

How should it look in my case? Maybe:
$allsort ="city";
$citysort ="state_or_region:";
$state_or_regionsort ="country";
$countrysort ="id";

Peppy
03-13-2005, 10:43 AM
ORIGINAL CODES:
COUNTRY CODE (If you click on a country the fannumber is shown and the members of this country are listed =
Australia 2 members
ID Name Email URL
[067] becky lorraine @ www
[062] Kassandra @ www )




<?
<?
include("config.php");
include("$header");

$query="SELECT * FROM $table WHERE apr='y' AND country='$id' ORDER BY $countrysort ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>

<h2>
<?
if ($num == "1"){
echo "$num Member";
} else {
echo "$num Members";
} ?> from <?=$id?></h2>

<p>See also the <a href="members.php?id=all">complete list</a> or <a href="members.php">browse by country</a>.</p>
<div align="center"><table border="0" cellspacing="0" cellpadding="5">
<tr>

<td><strong>ID</strong></td>
<td><strong>Name</strong></td>
<td><strong>Email</strong></td>
<td><strong>URL</strong></td>

</tr>
<?
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$name=mysql_result($result,$i,"name");
$email=mysql_result($result,$i,"email");
$url=mysql_result($result,$i,"url");
$hide=mysql_result($result,$i,"hideemail");
$id = sprintf("%03.0f", $id);
echo "<td>[$id]</td>
<td>$name</td>";

if ($hide != "h"){
$array = explode("@", $email);
$first = $array[0];
$last = $array[1];?>
<td><SCRIPT TYPE="text/javascript">
emailE=('<?=$first?>' + '@' + '<?=$last?>')
document.write(
'<A HREF="mailto:' + emailE + '">'
+ '@' +'</a>'
)
</SCRIPT></td>
<? } else {
echo "<td><s>@</s></td>"; }
if ($url == "") {
echo "<td><s>www</s></td>";
} elseif ($url !== "") {
echo "<td><a href=\"$url\" target=\"_blank\">www</a></td>"; }
{ echo "</tr>"; }

++$i;
}
echo "</table></div>";
include("$footer");
?>


MEMBER CODE (Shows Fannumber per country =
Australia 3 fans
Belgium 1 fan

and

lists fannames, urls, @ - sorted by =

ID Name Email URL Country
[019] Alicia @ www USA
[036] Ally @ www Canada
[040] Alyssia @ www Switzerland )




<?
<?
include("config.php");
include("$header");

if ($id == 'all'){
$query="SELECT * FROM $table WHERE apr='y' ORDER BY $allsort ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>

<h2><?=$num?> Members</h2>
<p>The complete list (view <a href="members.php">sorted by country</a>):</p>
<div align="center"><table border="0" cellspacing="0" cellpadding="5">
<tr>

<td><strong>ID</strong></td>
<td><strong>Name</strong></td>
<td><strong>Email</strong></td>
<td><strong>URL</strong></td>
<td><strong>Country</strong></td>
</tr>
<?
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$name=mysql_result($result,$i,"name");
$email=mysql_result($result,$i,"email");
$url=mysql_result($result,$i,"url");
$country=mysql_result($result,$i,"country");
$hide=mysql_result($result,$i,"hideemail");
$id = sprintf("%03.0f", $id);
echo "<td>[$id]</td>
<td>$name</td>";

if ($hide != "h"){
$array = explode("@", $email);
$first = $array[0];
$last = $array[1];?>
<td><SCRIPT TYPE="text/javascript">
emailE=('<?=$first?>' + '@' + '<?=$last?>')
document.write(
'<A HREF="mailto:' + emailE + '">'
+ '@' +'</a>'
)
</SCRIPT></td>
<? } else {
echo "<td><s>@</s></td>"; }
if ($url == "") {
echo "<td><s>www</s></td>";
} elseif ($url !== "") {
echo "<td><a href=\"$url\" target=\"_blank\">www</a></td>"; }
echo "<td>$country</td>";
{ echo "</tr>"; }

++$i;
}
echo "</table></div>"; ?>
<div align="center"><p>Powered by <a href="http://nothing-less.net/Nothing/you/script_fanbase.php" target="_blank">PHPFanBase</a> 2.0</p></div>

<? } else {
$query="SELECT DISTINCT country FROM $table WHERE apr='y' ORDER BY country ASC";
$result=mysql_query($query);
$num=mysql_numrows($result);
?>
<h2><?=$num?> Countries</h2>
<p>Here you can view the members sorted by country (click <a href="members.php?id=all">here</a> to view the whole list). Click on the country name to see the members from that country.</p>
<div align="center"><table border="0" cellspacing="0" cellpadding="5">
<tr>
<td><strong>Country</strong></td>
<td><strong>Fans</strong></td></tr>
<?
$i=0;
while ($i < $num) {
$country=mysql_result($result,$i,"country");

$query2="SELECT id FROM $table WHERE apr='y' AND country='$country'";
$result2=mysql_query($query2);
$num2=mysql_numrows($result2);

echo "<td><a href=\"country.php?id=$country\">$country</a></td>";
if ($num2 == "1"){
echo "<td>$num2 fan</td></tr>";
} else {
echo "<td>$num2 fans</td></tr>";
}

++$i;
}
echo "</table></div>";}

include("$footer");
?>

Please show me what I have to add or to change, if I want:
=> all countries sorted in alphabetical order
including the total fannumber of the country

if you click on a country
=> view states and regions of this country including the
fannumber of those states or regions

if you click on a state or region
=> view cities of this state or region including the
fannumber of those cities

if you click on a city
=> view name, year of birth, m/f, url and @ of the fans in this city!

Peppy
03-17-2005, 10:57 PM
Hi Mike!

The code modification is done - with some help of course!

I hope you did not start working on it already!

How ever thank you so much for offering your help - there will be a next time I guess!

Have a nice day!

Peppy

mwinter
03-18-2005, 12:11 AM
I hope you did not start working on it already!I did, though it was easier to start from scratch than modify that code. The quality is terrible, as is the schema. The queries are vulnerable to SQL injection attacks, the code isn't portable and wouldn't work at all on my server, parts are simply wrong (but can work under some circumstances). It's not a good excuse, but then again I did say it would take a while to complete based soley on the fact that I'd never seen the code before.

As I've started the project, I may as well finish it though I can fiddle more now.

Mike

Peppy
03-19-2005, 06:47 AM
Hi Mike! :)

I'd appreciate your help with solving the mentioned problems. (PM!)

THX