JavaScript and client side scripting.
Moderator: General Moderators
crazytopu
Forum Contributor
Posts: 259 Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:
Post
by crazytopu » Mon Jun 25, 2007 9:18 am
This is a bit strange. Does anyone know how to make it work. I have consulted this document and seems like I've done it right, still no luck.
http://uk2.php.net/variables.external
No data is being passed, newsLetter.php shows a complete blank page. I tried to echo something to test still nothing.
Note: it works fine when I use a button type submit. (i.e no image button).
Code: Select all
<form name="form_newsletter" method="post" action="newsLetter.php" onSubmit="return validateNewsLetter(form_newsletter);">
<table width="100%" border="0">
<tr>
<td colspan="3"><span class="style22">Please enter your email address</span> </td>
</tr>
<tr>
<td width="30%"><div align="right"><span class="style21 style22">News Letter </span></div></td>
<td width="47%" valign="top"><label>
<input name="news_email_txt" type="text" class="style13" />
</label></td>
<td width="23%"><label>
<input type="image" src="images/submit_newsletter.jpg" width="52" height="18" name="submit_newsletter" >
</label></td>
</tr>
</table>
</form>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Jun 25, 2007 9:20 am
What is your code for handling the submission?
crazytopu
Forum Contributor
Posts: 259 Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:
Post
by crazytopu » Mon Jun 25, 2007 9:27 am
Thanks . here is it:
Code: Select all
<?
include('includes/DbConnector.php');
$connector= new DbConnector();
?>
<?
if(isset($_POST['submit_newsletter'])){
/** test echo */
//echo "clicked";
/** for test purpose print email add*/
//echo "your email address : ".$_POST['news_email_txt'];
$insert = "INSERT INTO `newsletter` (`email`)
VALUES (
'".mysql_real_escape_string($_POST['news_email_txt'])."'
)";
//echo '<div>', htmlentities($insert), "</div>\n";
//echo '<br><div>', htmlentities($insert_to_member), "</div>\n";
if($insert_result = $connector->query($insert)) {
//echo "affected rows:", $connector->affected_rows(), "<br />\n";
//echo "id:", $connector->insert_id(), "<br />\n";
echo '<div align="center">
<span class=message> Thank you for subscribing to our newsletter </span></div> ';
}
else{
echo '<div align="center"><span class=error> There was an error, contact the technical support> ', $connector->mysql_error(), "</span></div><br />\n";
}
}
?>
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Mon Jun 25, 2007 9:30 am
Image submit buttons don't send their name, only the x and y value of the position you clicked on the image.
crazytopu
Forum Contributor
Posts: 259 Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:
Post
by crazytopu » Mon Jun 25, 2007 9:37 am
How do websites use image buttons with forms and use PHP to process those forms then?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Mon Jun 25, 2007 9:39 am
If there is only one image button you can change
Code: Select all
if(isset($_POST['submit_newsletter'])){
to
Code: Select all
if(isset($_POST['x']) && isset($_POST['y'])){
Moved to client side
crazytopu
Forum Contributor
Posts: 259 Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:
Post
by crazytopu » Mon Jun 25, 2007 9:46 am
Sorry, tried that. Didn't work. Any clue?
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Mon Jun 25, 2007 9:52 am
why dont you print the POST values to see what is being submitted. Im sure you can managed a bit of general debugging yourself
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Mon Jun 25, 2007 10:26 am
JayBird wrote: Image submit buttons don't send their name, only the x and y value of the position you clicked on the image.
Not quite true.
Image buttons do pass their name as well as the X & Y co-ordinates. Browsers will send 'submit_newsletter.x' and submit_newsletter.y'. However, PHP interprets the '.' as a '_', so the POST parameters you're looking for are $_POST['submit_newsletter_x'] and $_POST['submit_newsletter_y'].
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Mon Jun 25, 2007 10:38 am
Yes pickle, totally forgot about that. Im sure some browsers send different information, but cant find the info now. I know i had problems with is a couple of years back.
crazytopu
Forum Contributor
Posts: 259 Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:
Post
by crazytopu » Mon Jun 25, 2007 10:49 am
Thanks pickle and JayBird you too.