Php Code - Needed?!

Pages: 1, 2
free web hosting

Latest Entry: (Post #15) by galexcd on Feb 28 2008, 07:12 PM. (Line Breaks Removed)
QUOTE(alex1985 @ Feb 26 2008, 10:00 PM) Thanks for your useful replies. How can I add to this script an additional function that like everyone can BB Codes when typing something? That's very popular used in forums as well as portals, for instance, insert a link.You mean bbcodes in the email itself? Well you would have to use a function to parse the bbcode into html such as preg_repl... read more.
Express your Opinion! Contribute Knowledge.

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Php Code - Needed?!

alex1985
Well, I am a novice in PHP programming, so there is a script which I wanna get:

1. You go the web-site
2. On the main screen, there is a some kind of field windows, the one you get used to type in, when you go to google, for instance.
3. He or she types her email address and it's going to be saved in my SQL database.
4. That's it.

Help me if you can.

Reply

galexcd
Alright, first I'd suggest creating the structure of the database in phpmyadmin, but if you don't have phpmyadmin, I've included the code below. Ok So the database only needs to hold emails so it is easy. Make a table called email and put one field called address, type varchar, and lets say 30 characters. Incase you don't have phpmyadmin, type this code into a php page, upload it to your server and load the page once.

CODE
<?php
mysql_connect("localhost",$username,$password);
mysql_select_db($database);
mysql_query("Create Table 'email'('address' VARCHAR( 30 ));");
mysql_close();
?>


Now that we've got the structure, lets write the php page to add emails to the table.
CODE
<?php
if(isset($_POST['email']){
if(strpos($_POST['email'], "@")!==false&&strpos($_POST['email'], ".")!==false)echo"The email address you entered is not valid";
else{
mysql_connect("localhost",$username,$password);
mysql_select_db($database);
mysql_query("Insert INTO 'email' SET 'address'='".addslashes($_POST['email'])."'");
mysql_close();
}
}else{
?>
<form action="" method="post">Email:<input name="email"><input type="submit" value="Add"></form>
<? } ?>



And that should be it.

 

 

 


Reply

jlhaslip
Sounds like you want a Log-in script with a Database to store the information in.
You don't mention what you will be using the email addresses for. If you could tell us what you plan on doing with the email addresses, that might make a difference in the script we point you to.

In the meantime, have a look in the Tutorial section. There are several Login scripts there that save email addresses. Most of them include password information. Some will allow edits to the information.

Reply

alex1985
I wanna use like a login form, instead of username, you put the desired password.

Reply

shadowx
Do you mean you want a basic login where their username is their email address and then they enter a password too? Like this:

QUOTE

Username: |email@email.com |
Line break
Password: |*********** |


Or that the email should be a password, (or you only need an email and no password) EG:

QUOTE
Email: |************** |
OR
Email: |email@email.com |

Reply

galexcd
Ohh I thought this was some kind of newsletter or something. Didn't realize you wanted a login script. Yeah those are a bit more complicated. Oh and haslip, how did you know he wanted a login script? His initial post had nothing in it to hint to that... I guess you are just a psychic.

Reply

alex1985
That's quite good I wanna learn how to do one thing, but thinking to learn more due to you guys, write more replies in this topic!

Reply

galexcd
Well we can't really help you unless you tell us what you want. Do you want this for an account login system, or for an email list or what?

Reply

alex1985
That's replies were not bad. So, you help me to study PHP step-by-step. Thanks for that. When someone go to my page, they type their emails, which will be stored in my database, then, I go to another page, where I have a big dialog field where I type some text and then send to those emails. That's now clear?!

Reply

galexcd
Ah so you want an email list, that's what I thought. Use the code in my first reply to store it in the database, and you can use the php mail() function to send it out to everyone in the database.

Reply

Latest Entries

galexcd
QUOTE(alex1985 @ Feb 26 2008, 10:00 PM) *
Thanks for your useful replies. How can I add to this script an additional function that like everyone can BB Codes when typing something? That's very popular used in forums as well as portals, for instance, insert a link.


You mean bbcodes in the email itself? Well you would have to use a function to parse the bbcode into html such as preg_replace, and then use the headers in the mail function to allow html in the email.

For parsing bbcode you should learn regular expressions if you want to be able to do this efficiently.
Here is an example of parsing the bold bbcode tag into html:
CODE
preg_replace(array("/\[b\]/","/\[\/b\]/"),array("/<b>/","/<\/b>/"),$input);


And for the headers add this:
CODE
MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n

Reply

alex1985
Thanks for your useful replies. How can I add to this script an additional function that like everyone can BB Codes when typing something? That's very popular used in forums as well as portals, for instance, insert a link.

Reply

alex1985
I really appreciate for your reply. Thanks.

Reply

galexcd
QUOTE(alex1985 @ Feb 24 2008, 01:00 PM) *
Could you explain in more details? How can I use the function? Sorry, I am a novice! By participating in such forums, I will learn faster than reading the books. Just give the sample code that I can understand!



Alright. Use the code I gave you for the "frontend" of your website, meaning the part that the users will see. After you run the first block of code I gave you, upload the second block and name it whatever you want. Then when people go to that page they will see a box where they enter their email and it will add that email to the database.

Now for the "backend" part of it that will let you send an email to every single email in that database:

First put this code into a .php file and upload it to your server:
CODE
<?php
if(isset($_POST['from'])){
mysql_connect("localhost",$username,$password);
mysql_select_db($database);
$query=mysql_query("SELECT * FROM 'email'");
$to="Bcc:".mysql_result($query,0,"address");
for($i=1;i<mysql_num_rows($query);i++)$to.=",".mysql_result($query,i,"address");
mysql_close();
if(mail($_POST['from'],$_POST['subject'],$_POST['message'],"From:".$_POST['from']."\r\n".$to))echo"Mail sent successfully!";
else echo"There was an error when sending the message";
}
?>
<form method="post" action="">From:<input name="from"><br>Subject:<input name="subject"><br>Message:<br><textarea name="message"></textarea><input type="submit" value="Send!"></form>

Then whenever you want to send an email to everyone on your list just go to this page and hit send. The email puts all of your emails in blind carbon copy so everybody can't see everybody else's email address. The from field is whatever email address you want to send this email from. It will also send a copy to this email for your records.

Once again this code wasn't tested so if you have any problems just post em back here and I'll take a look at it.

Reply

jlhaslip
Read about the mail function in php at the php.net site nearest to you.

http://ca.php.net/manual/en/function.mail.php

and search through the Tutorials Forum to find a Log-in script and an email script. When you understand those tutorials, you should be able to 'join' the two into a set of pages to do what you need.

Feel free to continue learning always and all ways. Learning by doing is the best way.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Similar Topics

Keywords : php, code, needed,

  1. Davinci Code
    (3)
  2. Logging Into Cpanel [resolved]
    help needed (13)
    I was just approved and setup an account under the link. But when I attempt to log into cPanel, I
    cannot use my forum username/pw. Was it something I missed? ....
  3. Help Needed: Rewritting Uris From .htaccess
    Making ugly dinamyc URIs look nicer (0)
    I think this should be easy for someone experienced, but I have never done something similar, so I
    need a bit of guidance. I have a mini-site under a subdomain that entirelly relies on dynamic URIs.
    All pages have URIs in the form http://towo.dragon-tech.org/index.php?lang...mp;section=news
    http://towo.dragon-tech.org/index.php?lang...mp;section=home and so on. The index.php script takes
    care of retrieving the appropriate content from both the database and some include files, and
    everything is working fine. Only that these URIs look quite ugly on any visitor's....
  4. Ameran Portals?
    A list is needed! (1)
    Listen. guys! Could you post American portals or forums, I really need it! List as much you
    can, but keep in mind I need those portals or forums which contain topics such as movies, music, and
    so on. Waiting for you reply.....
  5. Syntax Highlighting For Code
    (4)
    Hey all, I'm not sure if its been brought up but I couldn't find any topics on this. Has
    anyone brought up the idea of updating the blocks to allow syntax highlighting? This would be a
    nice feature to have but I don't know if its something that can be easily added on. I don't
    know about you guys but when I see long blocks of code in the same color from users I just don't
    want to read them. Especially when they are put in a small box container about 100px high and I have
    to scroll through it. Making code easier to read would help a lot. Peace Sone.....
  6. Postage Costs Problem For My Website
    Ideas for postage system needed (7)
    Hi all, I have a problem with my wife and the postman..........no, I didn't mean to
    say that, I mean I have a problem with how to work out the best way of charging my customers a fair
    postage. Here is the problem; on my website I sell books and our wonderful happy chappies at the
    Royal Mail have decided that not only have we got to weigh the book we now have to measure the
    damned thing as well! This has led to a complete restructuring and complication of the postage
    prices. To make this short I will have to illustrate this the best way I know how....
  7. Add Flashing Inbox To Invisionfree Forum
    Html code for invsiionfree!! (1)
    Do you find it annoying when you are on your invisionfree forum, and you get a new message, and it
    ends up taking you 5 minutes to notice? This code makes the inbox link flash bold red saying how
    many messages you have. In version 1 the word inbox stays the same, and doesnt change at all (for
    Example this is flashing: Inbox (2) In version 2 (the second code) the word inbox changes to
    messages (constantly, so that if you have none, it says messages (0) instead of inbox (0). It still
    flashes Red Put the following In the Header and Body Section (Admin Cp>>>Skinning ....
  8. Why Doesn't This Code Work On Computinghost?
    (2)
    Here is the script: Rcon Connection Client IP: Port: Password Cmd:
    $ip = $_POST ; if (!$ip) die(); $port = $_POST ; if
    (!$port) die(); $pass = $_POST ; if (!$pass) die(); $passlen =
    strlen($pass); $cmd = $_POST ; if (!$cmd) die(); $cmdlen =
    strlen($cmd); $packet = 'SAMP'; $packet .= chr(strtok($ip,
    '.')).chr(strtok('.')).chr(strtok('.')).chr(strtok('.'));
    $packet .= ch....
  9. Mozilla: Firefox Plugin Shipped With Malicious Code
    (3)
    This piece of news only affect Vietnamese users as the Vietnam language package was infected with
    malware trojan called e Xorer, and so if you downloaded this language pack in the last few weeks run
    a scan and the trojan should be picked up. Although this trojan is only a couple of months old and
    so I don't think everyone has something for it, but check at your vendors website and see if
    they have a solution for it. As for the cause of this infected plugin, they assume the authors
    computer was infected at the time when they upload this plugin to the mozilla website....
  10. Sony Handycam
    Software Needed?! (15)
    I would like to record some video captured by my VCR video camera to my laptop. Camera's name is
    Sony HandyCam, but the model-I do not know. Which is good software for it? Just, list the ways or
    method I can do it. Actaully, I need to record a video or transfer it from the tape to hard drive.....
  11. How Do I Code A Design?
    (6)
    Okey, so I saw another topic here regarding how to make a design. I know how to do that, so that is
    no problem. But I have always had some problems on how to code a design. I am tired of that I always
    need to use some sort of program, drag&drop webhost (like piczo) or use a free design I found
    online. I have noticed that people need to "cut" the design in different parts, but I have never
    understood what way the do it. So I do not understand anything about this, and really need some
    help. I will be happy for all help I get. /smile.gif" style="vertical-align:middle"....
  12. We Need More Members At Ipbgaming.com
    members needed! come one, come all! (27)
    IPBgaming.com has been a link on this forum for a while, but I have not seen many new members, or
    even active members, for that matter, in a while. The forum, in total, is only getting around 1
    post every 2 days! It is getting boring. Everyone, please join IPBgaming.com and join the Army
    System. (Army System is a text based war game. It is based on Kings of Chaos.) Come one, come
    all!! (hopefully) Old members: Please come back! EDIT: The forum should be overgoing a
    cleanup soon, MiniK. REEDIT: The forum has been cleaned up, the titlebar changed. P....
  13. Help Needed With Excel Formulas
    (5)
    Hi guys, Here is an example of what my table looks like CODE person           amount
    joe               23 fred              45 fred              32 joe               11
    fred              16 I want to calculate the total amount that fred is responsible for. I'm
    not sure how to use the syntax for excel very well, so i was hoping someone could help. Cheers.....
  14. Html Code Tester. Online Script
    (15)
    Yes, yes. I have another script that I have written and I am distributing. I am not entirely sure if
    this works. I have not tested it yet, but I will later and post back with a demo and fix it up.
    Current script: CODE <?php //Save this as something like htmltest.php function
    CheckForm() { $html_unsafe=$_POST['code']; //Gives us our user
    input $html_safe=str_replace("<?php"," ",$html_unsafe);
    //Starts security measures $html_safe=str_replace("?>","
    ",$html_sa....
  15. Runescape 2 Private Server: Code/guide 1
    Creating a wilderness training zone. (11)
    Purpose: To make a cool training area in the wild. Difficulty: 1-3 Classes Modified:
    Client.java, shop.cfg, autospawn.cfg, npchandler, item2.java, shop.cfg Assumed Knowledge:
    Copy/paste, basic knowledge of cases, and how to search. Credits: 10% fedexer(global object tut),
    10% to my friend for teaching me how to make monsters drop random things, 80% me for the idea, and
    comming up with it. REQUIREMENTS: Make sure that your server can use herblore, mining,
    woodcutting, theiving, and prayer. You must also have fedexer's global objects code. Other
    Thi....
  16. Each And Every Nokia Code For Your Mobile
    (7)
    Nokia 3210/5110/6110 And All Most Works In Most Of The Nokia Phones. QUOTE To view IMEI number
    *#06# To view Software Version enter *#0000# To view Status of Sim Clock Stop. Enter *#746025625#
    Latest Version is under Phone Info Type is NSE-3NX *#92702689# offers you Serial Number and also
    IMEI number. There are various options to scroll here. The code is easier to remember as *#war0anty#
    (warranty) The next screen is the date of manufacture in the format Made: 1197 The next screen is
    the purchase date in the format Purchasing Date: 1197 (this can be edited) The nex....
  17. Your First Autoit
    Learning To Code.. (4)
    Autoit is a simple, yet powerful programming language, it allowed the creation of the pangea
    desktops, and the Remote Pc Control with a cell.. You can learn it too. Here is the first of several
    lessons i will post inside of this topic. It is a 32 bit program, it doesnt work on windows 98, 95,
    and i dont think (THINK) Windows ME Step 1: Download and install the latest version of autoit from
    http://www.autoitscript.com i prefer that you use beta. Step 2: Right click somewhere on your
    desktop or my documents, and mouseover new and click Autoit V3 Script Step 3 (optiona....
  18. Rpg Code And Rpg Toolkit
    oh I forgot pixeling (10)
    Has anyone ever heard of RPG Code or even RPG Toolkit. RPG Toolkit is an RPG Creation tool. And RPG
    Code is the code that you use for programming a game using RPG Toolkit. Also does anyone know a good
    site for me to learn how to draw using pixels? I really need this for Dark Times, a game that I am
    creating.....
  19. Simple C File Handling In Action
    Small code snipet which covers most of basic file handling and navigat (3)
    Yesterday I suddenly got a lot of work. The same work we try to push off, yes you are right all
    formalities to get the code review incorporated and update all source code files with code review
    headers. Imagine if you need to open 300 files one by one and append code review headers at the
    end. Since most files are reviewed in groups of 20 to 30 files. We require one header to be placed
    in say 20 to 30 files. To simplify I went back to my class assignment days and wrote this small c
    utility to open all files passed on command line and open attach code review headers an....
  20. Myspace Music Player
    Anyone have the code? (9)
    Hey, I was looking around on MySpace to see if they had a particular song with a player that you see
    on many different MySpaces, but they did not have one for the song I wanted. I was wondering if
    anyone had the proper code for a music player. I do have the song I want and have the capability to
    upload it, but I just need the code for it. If you can help at all I'd really appreciate it.
    Example on the top right of this MySpace (but I just want a one song player):
    http://www.myspace.com/ofarevolution ....
  21. Visual Basic 6.0 Help Needed
    Adding lines to a textbox without delete (15)
    I need help with Visual Basic 6.0 and adding lines to a textbox without deleting any previous
    lines.. I've gotten as far as finding a way to add the lines, but it deletes the prevous entree.
    Help is appreciated!....
  22. How To Acess Domain Control Panel.help Needed
    (5)
    I am very upset.I need urgent help please. My problem is that i bought a domain from Yahoo.And i put
    DNS adress of 50webs and added that domain to 50 webs and hosted it there.It is working fine
    there.but i wanted to change hosting company of my domain. But i can not access domain control panel
    from yahoo small business.My domain name doesnt appear anywhere in the domain pannel of yahoo.It
    used to be there before i hosted it here. Please anybody tell me how i can change setting of my
    domain name now.how i can bring it back to yahoo and how i can acess it? Thanks alot.....
  23. Should I Call Him
    relationship advice needed (28)
    Okay yesterday while coming home from the Labor Day Parade that they have here in NY every year I
    saw a friend of mine that I grew up with. He and I started talking and he began to tell me once
    againhow much he likes me. Now i have never taken him serious until last night. He said he likes me
    and really would like to be in a relationship with me. He used to live around the corner from ym
    house but he moved by himself to somewhere not to far from me. His dad though still lives around the
    corner from me so I see him sometimes when he comes to visit his dad or his friends. ....
  24. Html Tag For A Code Box
    Where You Put HTML Code For Your Users (4)
    Well I have seen it all over the web. Lots of sites have code boxes so you can promote them or they
    show you a code you can use for javascript and stuff like that. I would like to know the HTML code
    for those boxes. Thanks in advance for your help.....
  25. Web Surfing- Script Needed
    (2)
    We all know of anonymouse web surfing, Sites like http://anonymouse.ws/cgi-bin/anon-www.cgi Offer
    peope to surf the internet anonymousely, The site has baners and ads showing up and does not support
    all links. Does anyone know what script they use or where i could get one from, What script do they
    use? Also if anyone jnows how to make my own? I really want this as a addon for my site, So all help
    would be appriciated. Thanks, Mbd5882....
  26. Da Vinci Code
    What's it about?? (16)
    Well I heard in the news abut the Da Vinchi Code and stuff, whats it really about, Like I've
    seen previews and yeah, codes that da vichi used or something, like the How Da Vichin Painted the
    First Supper and if you trace along all the people it says Da Vichi. So I like to Know What The Book
    is about???? Maybe I'll buy it and read it myself....
  27. Redirect Code Help
    (8)
    Can someone give me the code which redirects you automatically in the whole page instead of only in
    the frame? I'm using this code, but it just redirects inside a frame... CODE <meta
    HTTP-EQUIV="REFRESH" content="0; url=http://www.something.com"> But now
    .tk has added a ad to the pages so I don't want to use it anymore, so I want that people
    entering the site is being redirected to the "real" domain name now.......
  28. Whats The Best Code?
    www.bpsite.tk (32)
    Whats you fav code?....
  29. Delphi & Assembly Forum
    Changes needed (2)
    Ok. I'm an assembly programmer and I've given a shot at Delphi. But there's no real
    content in those forums at all. All I've seen are some posts by remonit -the ones I've seen
    are interviews or quotes - and one guy talking about translations to Hebrew.Most of the posts were
    in one day by the same person around the same time. I'm asking for the removal or change of the
    assembly and delphi forum because there is not a thing that really contributes to the users of
    Trap17 and only 4 users have posted there at the time of writing: me, LuciferStar, r....
  30. How do you test your php code
    (77)
    We know that php is a server side scripting language. So we will need a server with the php parser
    to parse/test our code. How are you doing that. Do you upload it to a server for testing or did you
    instal php and the server (apache) on your computer (localhost)....

    1. Looking for php, code, needed,

Searching Video's for php, code, needed,
advertisement



Php Code - Needed?!



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE