Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-20-2006, 10:50 PM   PM User | #1
nailbender963
New to the CF scene

 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
nailbender963 is an unknown quantity at this point
changing command button to text link?

i'm trying to format a little code i found on hot scripts and have run into a problem trying to replace the submit button with a text link that will do the same thing. here's the code.

<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>?do=add">
Email Address: <input type="text" name="email"><br>
<input type="submit" value="Submit">
</form>

i just think that links look better than buttons.

any help would be greatly appreciated.

thanks
nailbender963 is offline   Reply With Quote
Old 08-20-2006, 11:00 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
PHP Code:
<a href="#" onclick="document.form1.submit();">Submit</a
You'll need to name your form.
Fumigator is offline   Reply With Quote
Old 08-21-2006, 12:41 AM   PM User | #3
nailbender963
New to the CF scene

 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
nailbender963 is an unknown quantity at this point
thanks for the line but could you give me a clue as to how i name the form?

<form action="<? echo ($_SERVER['PHP_SELF']); ?>" method="post" >

i remember when i did this with my paypal buttons i had to rename everything to get it to work but with this i'm lost.

thanks
nailbender963 is offline   Reply With Quote
Old 08-21-2006, 01:16 AM   PM User | #4
Crowds
Regular Coder

 
Join Date: May 2005
Posts: 235
Thanks: 0
Thanked 0 Times in 0 Posts
Crowds is an unknown quantity at this point
PHP Code:
<form name="form1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>?do=add">
Just add name="form1"

Crowds
__________________
PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design
Crowds is offline   Reply With Quote
Old 08-21-2006, 01:38 AM   PM User | #5
nailbender963
New to the CF scene

 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
nailbender963 is an unknown quantity at this point
i must have some other problems the script's not working.

thanks for your help.
nailbender963 is offline   Reply With Quote
Old 08-21-2006, 02:01 AM   PM User | #6
Crowds
Regular Coder

 
Join Date: May 2005
Posts: 235
Thanks: 0
Thanked 0 Times in 0 Posts
Crowds is an unknown quantity at this point
What exactly is going wrong ?

Did it work before you changed things ?

If so, Lets have a look at the original script (before you changed the link to text rather than button) to see if we can spot anything.

Crowds
__________________
PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design
Crowds is offline   Reply With Quote
Old 08-21-2006, 05:35 AM   PM User | #7
nailbender963
New to the CF scene

 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
nailbender963 is an unknown quantity at this point
okay i got the script working and everything looks good but i'm back to the button thing. i'm sorry to be beating a dead horse here but this is the code i'm working with now. i need to mention that the original code i submitted was an error on my part, sorry.

okay here it is:

<form action="<? echo ($_SERVER['PHP_SELF']); ?>" method="post">
Your Email: <input type="text" name="email"><br><br>
<br><br>
<input type="submit" name="submit" value="Submit">
<input type="hidden" name="sent" value="yes">
</form>

so i add this:

<a href="#" onclick="document.form1.submit();">Submit</a>

and then name the form like this:

<form action="<? echo ($_SERVER['PHP_SELF']); ?>" method="post" name="form1">

and i get nothing. it just refreshes the screen.

what do you think, and thanks again for all the help
nailbender963 is offline   Reply With Quote
Old 08-21-2006, 10:37 AM   PM User | #8
Crowds
Regular Coder

 
Join Date: May 2005
Posts: 235
Thanks: 0
Thanked 0 Times in 0 Posts
Crowds is an unknown quantity at this point
There has to be more code to it surely ?
Otherwise refreshing the screen is all it will do !
Is there no more php and/or javascript near the start of the page ?

Crowds
__________________
PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design
Crowds is offline   Reply With Quote
Old 08-21-2006, 01:32 PM   PM User | #9
nailbender963
New to the CF scene

 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
nailbender963 is an unknown quantity at this point
i've looked at the entire app but i can't find where the rest is. if you care to take a look here's the link. www.theangrypoet.com/email/

i can only think of two places it would be, the config file and the index file but as i have said before i'm not good at this at all.

thanks
nailbender963 is offline   Reply With Quote
Old 08-21-2006, 03:52 PM   PM User | #10
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
First and foremost, you need to validate your html. You have four <html> tags, three </html> tags, mismatched <p>, <span>, and <center> tags, and a number of other simple problems that need to be fixed.

With regards to your submit link, it will do the same thing a submit button will do, but you must make sure in your PHP code you are not referencing $_POST['submit'] anymore, as that form control is no longer there. Without seeing your PHP code (you may want to post it), that's what I suspect is happening.
Fumigator is offline   Reply With Quote
Old 08-21-2006, 03:53 PM   PM User | #11
Crowds
Regular Coder

 
Join Date: May 2005
Posts: 235
Thanks: 0
Thanked 0 Times in 0 Posts
Crowds is an unknown quantity at this point
Well I can look at the page you link to but it will not display any php if I view the source.
Your form action is set to the same page that the form is on. Which is only any good if the page has some php on it, Which it must have because it seems to work. I submit an email and it says it has been submitted. What is it that is not working ?

Post the entire code of the page up here (enclose it in php quotes to make it easy to see what is going on, see just below the attachnents drop down in the reply window)
And lets also have a look at the config page (change any sensitive areas such as passwords or database connection details before posting)

Crowds
__________________
PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design
Crowds is offline   Reply With Quote
Old 08-22-2006, 12:52 AM   PM User | #12
nailbender963
New to the CF scene

 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
nailbender963 is an unknown quantity at this point
call it an ocd thing but i really don't like buttons, in fact i hate them. when i first saw this app on hot scripts and started to play around with it i really liked it because i could make it look just like my site, which if you can tell from my coding skills is more important to me than say, function.

that said all i would like to do is replace the button that says submit on the page with a text link. trust me crowds, the only script on the file "form.inc" is what i have posted. all the other script is scatered throughout the folder that the app is contained in on the site/server.

if you like i can make a zip file link on my site with the entire app that you can download.

and, sorry for all the trouble. i really appreciate all the attention all of you have given my little problem




file name: index.php
PHP Code:
<?php
require "config.php";
include 
"header.inc";
if (isset(
$sent)) {
if (!
$rfields == "") {
$rfields explode(","$rfields);
for(
$i 0$i count($rfields); $i++) {
if ($
$rfields[$i] == "") {
echo 
"You have not completed the required field <b>$rfields[$i]</b>. Please click <a href=\"javascript:history.back(1)\">here</a> to go back and complete the required field. Thank You.";
exit;}}}
if (!
ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.
'@'.
'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$'$email)) {
echo 
"Your email address, $email, does not seem to be valid. Please click <a href=\"javascript:history.back(1)\">here</a> to fill in a proper email address. Thank You.";
exit;}
$fmail "The below named has requested to be registered to your mailing list. The following contains the information that was submitted via the online form.\n\n";
$fmail.= "IP Address: $REMOTE_ADDR\n";
$fields array_keys($HTTP_POST_VARS);
for(
$i 0$i count($fields); $i++) {
    
$temp $fields[$i];
    if (
$temp == "rfields" || $temp == "submit" || $temp == "sent" || $temp == "y_name" || $temp == "y_email" || $temp == "autor" || $temp == "autor_message" || $temp == "$autor_mail" || $temp == "$autor_subject" || $temp == "after")
        
$fmail $fmail;
    else {
        
$temp1 stripslashes($HTTP_POST_VARS[$temp]);
        
$fmail.= "$temp: $temp1\n"; }}
$fmail.= "\nSent From (http://www..com)";
$mailed mail($y_email"Subscription Registered"$fmail"From: $name <$email>");
if (
$autor == "yes") {
        
$autor_subject stripslashes($autor_subject);
        
$autor_mail stripslashes($autor_mail);
        
mail($email$autor_subject$autor_mail"From: $y_name <$y_email>"); }
if(!
$mailed) {
echo 
"There was an error. Please contact <a href=\"mailto:$y_email\">the Webmaster</a>?"; }
echo 
"<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=./write.php?email=$email\">";
} else { 
?> <BR>
<? echo "$body_text"?><BR>

<? include "form.inc";}
include 
"footer.inc";
?>

file name:config.php
PHP Code:
<?php

// Enter the relative path to the re-direct page.  A thank you 
// Page is included in the script. 
$after "./thankyou.php";

// This is the page title that you would like to appear when a 
// user subscrbes to the list. 
$page_title "subscription page";

// Name of the e-mail list.  Best to leave this one alone. 
$writefile "email";

// Name of file to write your e-mail list to, the file should be 
// writable by your server.  Best to leave as-is. 
$outfile "emails.txt";

// Leave this vairable as-is for best results.  It format's each line 
// So that the script can read your e-mail list. 
$writestring "$email\n";

// I really don't remember what this is or why I put it in here, but
// I am sure there was a good reason for it so just leave it here. 
$y_name "Subscription";

// Again, I beleive I was asleep when I put this in, just leave it alone.
$rfields "email";

// Your name and e-mail address go here, (e-mail address in the sincle quotes
// and brackets and name in quoted area.  
$from_mail " <'steve@.com'>";

// Your e-mail address goes here for the subscription notification.
$y_email "steve@.com";

// Set to "yes" to turn on the autorespond, off the decline. 
// autorespond will send the subscriber an e-mail notice that
// they have been added to your list.
$autor "yes";

// Subject of the autorespond e-mail goes here. 
$autor_subject "Thank You,  Newsletter";

// This is the welcome message that the user sees when they go to your
// signup page.
$welcome_msg "Thank you for chosing to register for our newsletter.";

// This is the page test below the welcome message.
$body_text "Please fill out the form below to begin receiving our newsletter. <BR> <b> Be sure to enter your correct e-mail address in the complete format like: \"me@mydomain.com\". ";

// This is the body of the autorespond e-mail that is sent to the user. 
$autor_mail "Either you or someone else has requested registration in our free newsletter.  This email is being sent to you because you or someone else requested it.  IT IS NOT SPAM.  If you did not request this information, please unsubscribe at: http://www..com.";

?>

file name: form.inc
Code:
<form action="<? echo ($_SERVER['PHP_SELF']); ?>" method="post">
Your Email: <input type="text" name="email"><br><br>
<br><br>
<input type="submit" name="submit" value="Submit">
<input type="hidden" name="sent" value="yes">
</form>


file name: write.php
PHP Code:
<?php
  
  
include("config.php");
  
// Open file for APPENDING! NO DATA LOST!!!
  
if(!$fd fopen($outfile"a")) {
    echo(
"Error opening file.");
    exit;}

// Write the string to the file.
    
if(!fwrite($fd$writestring)) {
    echo(
"Error writing to file.");
    exit;}

  
fclose($fd);

include(
"./thankyou.php");
?>

there are six other files in this app and from what i can tell they have noting to so with my problem.

they are:

colors.txt
footer.inc
header.inc
send.php
view.php
thankyou.php


thanks again

btw crowds, can't you access a pages code buy writing the url into your editor? i do it all the time with html kit.
nailbender963 is offline   Reply With Quote
Old 08-22-2006, 01:09 AM   PM User | #13
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
header.inc and footer.inc are brought into your index.php. Based on what's in those two files could directly relate to your problem.

PHP code can't be read just by going to that url; the PHP interpreter, well, interprets the code and produces output to the browser. There's no way to see the code that produced the output without the source file.
Fumigator is offline   Reply With Quote
Old 08-22-2006, 01:35 AM   PM User | #14
nailbender963
New to the CF scene

 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
nailbender963 is an unknown quantity at this point
file name: header.inc
PHP Code:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo "$page_title"?></title>
<style>
<!--
a{text-decoration:none}
//-->
</style>
</head>

<body link="#66CCCC" vlink="#66CCCC" alink="#66CCCC">
<font face=verdana,arial>
<STYLE type="text/css">
    BODY {scrollbar-3dlight-color:#dedf9f;
           scrollbar-arrow-color:#8eb6d2;
           scrollbar-base-color:#FFFFOO;
           scrollbar-track-color:#FFFFOO;
           scrollbar-darkshadow-color:#cccccc;
           scrollbar-face-color:#99CCFF;
           scrollbar-highlight-color:#eeeeee;
           scrollbar-shadow-color:#008000}
  </STYLE>
<a href="http://www.mykazaam.com"><img src="logo.gif" border="0"></a><br>
<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
          <tr>
            <td class="catHead" height="25"><span class="genmed"><b><? echo "$page_title"?></b></span></td>
          </tr>
          <tr>
            <td class="row1" align="left"><span class="gensmall" style="line-height:150%">
        <? echo "$welcome_msg"?>
             

            </span></td>
          </tr>
        </table>
file name: footer.inc
PHP Code:
</CENTER>
</
span></td>
          </
tr>
          <
tr>
            <
td class="row3" align="left" height="24"><span class="gensmall"><b><a href="http://www.mykazaam.com">www.mykazaam.com</a></b>
            </
span></td>
          </
tr>
        </
table>
        
        
</
body>
</
html
nailbender963 is offline   Reply With Quote
Old 08-22-2006, 05:03 AM   PM User | #15
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
I can't see anywhere that $_POST['submit'] is being referred to explicitly apart from that loop that adds all the $_POST variables to $fmail, which shouldn't be a problem if there's no $_POST['submit'].

In any event, you can always add a hidden input field to your form and name it submit with a value of submit; that should adequately simulate the submit button.
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 +1. The time now is 03:04 AM.


Advertisement
Log in to turn off these ads.