Jump to content

[SOLVED] Mailing Form with song download link


bucksie

Recommended Posts

Hey all,

 

Newbie here and im hoping someone can help me.

 

Im making a very simple webpage for subscribing to a bands mailing list, in summary it will have a photo then three text boxes where users enter;

 

1) Name

2) Email

3) Answer a question (spam proof)

 

Once they submit the info they are shown a download box on the very same page where they can download a free mp3 song.

 

I have the html and css done for the page but its the php file that i cant figure out.

 

Anyone be able to help me with the code ?

 

Cheers,

John

Link to comment
Share on other sites

Here is the code how to do it, but first you need to have 2 pages: One with a form on it, and the other page where the link for the free mp3 will be. Let's call the first page form.html and the next one mp3.html so that you can understand the code more easily. :-) What we will do is to call the form.html or the mp3.html in the same page when the user submits the info.

On the form.html page you have a form with your fields and stuff. Find this line in your code:

 

<form action="the_page_where_the_form_will_be" method="POST">

Change the "the_page_where_the_form_will_be" with the name of the page where you will put your form.html in. After your changed that, find the code for the submit button. It goes something like this:

<input type="submit" name="some_name_will_be_here" value="some_value">

Remember the "some_name_will_be_here", because you will need soon.

Now, on your index page, or whatever page you will put your form, insert this code where you want your form (this is php, by the way):

 

<?php

if(!isset($_POST['some_name_will_be_here'])) {

include "form.html";

} else {

include "mp3.html";

}

?>

 

Did I say it's done? Well, now I say it. This is all the wisdom. :-) I hope you understand everything. :-) If it's your band, I hope you will have a lot of subscribers! :-) Cheers!

Link to comment
Share on other sites

Thanks Adika, sadly im next to useless when it comes to php.

 

This is the html code i have;

 

<title>Free Download</title><form action="feedback.php" method="post">

  <table width="350" border="0" align="center" cellpadding="1" cellspacing="1" summary="mailing list">

    <tr>

  <td height="24" colspan="2" valign="middle" class="font"><p> </p></td>

  </tr>

  <tr>

  <td height="24" colspan="2" valign="middle"><div align="center">

    <p><span class="font"><img src="bss.jpg" width="350" height="350" alt="bss" /><br />

 

    </span></p>

  </div></td>

  </tr>

<tr>

  <td height="25" colspan="2" valign="middle"><span class="font">Join our mailing list to download our new track "Lies" for free!!</span></td>

</tr>

<tr><td width="105"><span class="font">

  <label for="name">Name</label>

  :</span></td>

 

  <td width="232" align="right"><span class="font">

    <input type="text" name="name" id="name" size="25" />

  </span></td>

</tr>

<tr><td><span class="font">

  <label for="email">Email address</label>

  :</span></td>

  <td align="right"><span class="font">

    <input type="text" id="email" name="email" size="25" />

 

  </span></td>

</tr>

<tr>

  <td> </td>

  <td align="right"><span class="font">

    <input name="Submit" type="submit" value="Get it" />

  </span></td>

</tr>

 

 

<tr>

  <td colspan="2" class="line"> </td>

</tr>

 

<tr>

  <td colspan="2" align="center" class="font"><span class="font"><a href="http://www.myspace.com">Return to our mySpace</a></span></td>

</tr>

 

  </table>

</form>

 

My feedback.php file is emty at the moment because i was messing around with different php code and nothing was working the way i wanted it to.

 

Any help ?

Link to comment
Share on other sites

Do you know how to send mail with php? If you don't than check out the mail() function from php.net If you have some questions about it after you checked out that function, then write me.

 

Let's put your download page into single file, so when the user submits the form, the mp3 link will still show himself on this page. So, this page will be feedback.php

 

Let's code it all in one file. :-) Here is the complete, ready to be tested, feedback.php page. Just copy all the code and save it as feedback.php and test it.

 

<html><head><title>My websites name</title></head><body>
<?php
if(!isset($_POST['Submit'])) {?>
<form action="feedback.php" method="post">
  <table width="350" border="0" align="center" cellpadding="1" cellspacing="1" summary="mailing list">
    <tr>
  <td height="24" colspan="2" valign="middle" class="font"><p> </p></td>
  </tr>
  <tr>
  <td height="24" colspan="2" valign="middle"><div align="center">
    <p><span class="font"><img src="bss.jpg" width="350" height="350" alt="bss" /><br />

    </span></p>
  </div></td>
  </tr>
<tr>
  <td height="25" colspan="2" valign="middle"><span class="font">Join our mailing list to download our new track "Lies" for free!!</span></td>
</tr>
<tr><td width="105"><span class="font">
  <label for="name">Name</label>
  :</span></td>

  <td width="232" align="right"><span class="font">
    <input type="text" name="name" id="name" size="25" />
  </span></td>
</tr>
<tr><td><span class="font">
  <label for="email">Email address</label>
  :</span></td>
  <td align="right"><span class="font">
    <input type="text" id="email" name="email" size="25" />

  </span></td>
</tr>
<tr>
  <td> </td>
  <td align="right"><span class="font">
    <input name="Submit" type="submit" value="Get it" />
  </span></td>
</tr>


<tr>
  <td colspan="2" class="line"> </td>
</tr>

<tr>
  <td colspan="2" align="center" class="font"><span class="font"><a href="http://www.myspace.com">Return to our mySpace</a></span></td>
</tr>

  </table>
</form>
<?php
} else { 
// since I have some free time, I will provide you the code for mail sending

$name = $_POST['name'];
$email = $_POST['email'];

// Lets create the mail first
$subj = "New subscriber";
$to = "myemailaddress@somewhere.com";
$message = "New subscriber! Name: ".$name."\n\rEmail: ".$email;
mail($to,$subj,$message);
?>
Put here your download page html. The rest is just a simple example.....
<br><br><br>Download my music <u>The link to my music</u>. This is pure html stuff, so you know what to put here. :-)
<?php
} ?></body></html>

Link to comment
Share on other sites

As for anti-spam you don't need a question thats old way of fixing this the new way... is storing everyone who submits the feedback's IP into a list.. and checking the list if someone submitted it then they cannot submit it for XX hours/days or EVER.. unless you empty the list.. its a permanent fix to any spam problem. People don't even use captchas due to just ip checking. It's easy to implement the ip check as well just google ip logging simple script

Link to comment
Share on other sites

As for anti-spam you don't need a question thats old way of fixing this the new way... is storing everyone who submits the feedback's IP into a list.. and checking the list if someone submitted it then they cannot submit it for XX hours/days or EVER.. unless you empty the list.. its a permanent fix to any spam problem.

 

It's a temporary problem against spam, because the spam bots generate different IPs every time they attack. And soon your ip blocking list can grow to the hundreds of records, and you will keep getting a lot of spam (in case your site becomes very popular). I know this because I had a guestbook on one of my websites that was doing that ip blocking thing, and he never managed to keep spam away. What was even worse is that the same spam message appeared again and again during the week but from different IP address. After I installed a simple captcha, the spam was minimal, only one or two every two weeks. Before, it was one or two every day. The site was never big enough to test it fully against spam, but captcha is more better than any IP blocking script. And it's better if you have even the simplest anti spam technology (captcha or the Answer a question (if this works at all, since I never tried it)) than if you don't have none, because ip blocking is NOT an anti spam techology any more. :-)

Link to comment
Share on other sites

Ummm, hate to be the bearer of bad news O.o.

But i submitted a blank form and got the MP3 download, if i was you i would add a.

 

  // CHECK POST ENTRY
  if($_POST['name'] == "") {
      echo "Please provide a name";
  exit;
  }

  if($_POST['email'] == "") {
      echo "Please provide a valid email";
  exit;
  }

 

Before the actual submit code, cheers breana!

 

Edit, if you need a spam protection i can make you one :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.