alex1985
Feb 21 2008, 05:04 PM
| | 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
Feb 21 2008, 05:57 PM
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
Feb 21 2008, 06:01 PM
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
Feb 21 2008, 09:59 PM
I wanna use like a login form, instead of username, you put the desired password.
Reply
shadowx
Feb 21 2008, 10:12 PM
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
Feb 21 2008, 10:45 PM
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
Feb 22 2008, 11:45 AM
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
Feb 23 2008, 01:29 AM
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
Feb 23 2008, 09:27 AM
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
Feb 24 2008, 01:45 AM
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
Feb 28 2008, 07:12 PM
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
Feb 27 2008, 06:00 AM
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
Feb 25 2008, 06:04 AM
I really appreciate for your reply. Thanks.
Reply
galexcd
Feb 25 2008, 01:33 AM
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
Feb 24 2008, 11:50 PM
Read about the mail function in php at the php.net site nearest to you. http://ca.php.net/manual/en/function.mail.phpand 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
Similar Topics
Keywords : php, code, needed,
- Create Table - Mysql Code - Help
(1)
Php Source Code Unveiled In Browser?
is that possible? (7) I am quite new to PHP and this concern came to my mind after playing around a bit with it... When
PHP is not correctly configured on the web server the source code of a php file we try to access
through a browser will be shown instead of the result of the code itself. This will normally not
happen when PHP is working properly, but I was just wondering if it could still be possible to see
that code if a user wanted to or if something on the server failed. This would for example expose
sensitive information like mysql passwords and so on... Is anything like that possib....
Malicious Code Injection
(3) Hi everyone! This is my first post, so be kind! Basically, I'm trying to get a free
host together so am writing some posts. Here's a little summin' summin' about malicious
code injection with PHP applications. Basically, this security exploit is one of the oldest tricks
in the books and all comes down to the fact that PHP allows execution of both local and remote
scripts with the SAME function... dur. Anyway, this is how it works. Image you've just employed
a young go getter, straight outta uni, who has found becoming a Jack of all trades a ....
Tutorial Needed?!
PHP+Ajax (11) I need many tutorials based on PHP programming language and AJAX technology. Those tutorials might
be of any kind. Please post only the links to the trusted and working tutorials!....
Php And Mysql Programming
anyone knows a code for mysql and php (2) hi everyone! I am making a program using php and mysql...I am a noob on this so i need your
help guys...I want to make a simple program that will some values and then store them on a database
and then retrieve them...uhmm let me give an example out put of what i need. This is the example
say..: Enter First Name: Enter Last Name:
Enter Age: Enter Address: ..those
are the data needed for input values...my question now is how can I make a database....
Admin Page
Tutorial Needed? (4) I need to look at a nice tutorial how do you create an admin access page with many functions as many
as possible.....
Tools Needed!
PHP & MySQL (9) Hello, everyone! I need some tools for those two things to test PHP scripts coming together with
database on my laptop, instead checking them on a web-server which takes time.....
Php Code Needed Iii
(10) Hello, everyone. I need your help again! Who might create the PHP code, the picture is
above this text. Basically, I want when the user fill in all the information in this form, it
automatically was sent to my email. And, then, the dialog box appears or on the same window, it was
said that your request has been sent. Moreover, if the user did not fill the entire information,
the dialog box appears stating that you did not fill some field. Thanks, for help. You always do
that.....
Looking For Command Line Based Sql Modification
Program Needed For SQL? (1) How I use Windows command prompt client and do modifications to my SQL database. If yes, please
write the commads I should know for that. If no, please get me the software with which I can do it.
Topic title modified. Proper English is always required when posting in our forum. ....
Php Code?
Mathematical Applications (12) Hello, everyone. The help is needed again. How can I make calculator in PHP language? That will act
like that a user just type in the fields known values, then click the button, and it's going to
be solved automatically. In other words, have can I write a formula in PHP, how to plug it inside
that language. For example, the formula to find a peremeter of square is: P=4a. So, a user
just can write the known value which is peremeter itself and it will find the side of a square; and
vice versa. If you can write many things how to do such formulas, such as comp....
Php Code Needed
Working Together? (5) Hello, everyone. I need your help again. This forum is quite good for it. Well, I need create a
registration form for my web-site using PHP and SQL. The information it should contain: 1) User
Name 2) First Name 3) Last Name 4) Password 5) e-mail Address 6) Security Image: that images helps
to protect a random registration, for instance, 56+2=where user have to type an answer in order to
finish registration. That's all for today. Anymore things, I will post another post over here.
....
Slaed Cms
Book Needed!!! (2) Hello, everyone! I need some tutorial for Slaed Engine for any version you might find. I wanna
learn how you can make modules or blocks for this CMS. Especially, library functions and other
things that will make the web-site works like virtual library.....
Use Rss In Php Code
(3) so, how can I make RSS reader on my website? thanks in advance....
Will This Code Work
php linking script ?p= (5) hi i'm not that great at php so i'm not to sure if this will work or not. but what i want to
do is be able to use ?p=staff or what ever page name, with out the php extion, and i would like to
no if this simple script i made would work. the code is: CODE <?php $p =
$_GET['p']; if ( !empty($p) &&
file_exists('./' . $p . '.php') && stristr( $p, '.'
) == False ) { // pages = directory where you store your pages $file = './'
. $p . '....
I Need Some Proof Reading For My Code Please! [resolved]
(7) Well... everything is fine except the Content Select section (refer to the in-code headings)...
thats where it says the error is... could anyone find out why it wont work when I click one of my
links? http://2kart.trap17.com/progress.php for an example of what happens...
//----------------- //portfolio paths //----------------- $portfolio = "/portfolio"; $lay
= "/images"; //------------------ //navigation //------------------ $link = · Home
html; $link = · Portfolio html; $link = · Programming html; $link = ....
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....
Awesome Source Code Viewer Script
(7) Hello! I have just came up with a sweet script to show the source code of any website and it
only requires one file. This is the basis of the script and can be customized with CSS and other
things and can be instituted as a public resource. Well I will provide the code and a step-by-step
tutorial on each of its parts. This code has been tested by me. Enjoy! CODE <?php
//This little tag starts our php script and is easily the most important part of the script. //We
will start our base script here. //You can change some of the styles used here to your des....
Wamp Packages Needed To Test Scripts
Set up Apache, PHP, etc on your machine (1) In order to test php scripts on your localhost machine, you require a system that includes php
parsing. A WAMP set-up 'usually' includes a database server, and a database manager, too.
For Windows machines, theses are usually referred to as WAMP because they include Apache, Mysql, and
PHP for Windows, hence the acronym WAMP. Wikipedia has a listing of the available packages with
details about the included versions and often a link to the wikipedia article describing them. The
list can be found at http://en.wikipedia.org/wiki/Comparison_of_WAMPs Personally, I....
Whats Wrong>?
please see this piece of code and see whats wrong: (9) CODE require('connection2.php'); $select=mysql_query("SELECT * from
`users` WHERE password='$_GET[password]'");
$co=mysql_num_rows($select); if ($co = 1) {
session_start(); $s=session_id();
$_SESSION['access']="yes";
$username=$_GET['username'];
header("location:../main/index2.php?a=$_GET[username]&s=$s"
;); //echo "<a href='.&....
Creatting A Playlist Through Php
script help needed (5) Hi I am trying to make a script so that i can insert songs into a playlist, but i need a script in
which it opens the playlist file and removes the closing tag at the end, so before i can add more
entrys. e.g CODE <atx> <entry>Location 5</entry> <entry>Location
4</entry> <entry>Location 3</entry> <entry>Location
2</entry> <entry>Location 1</entry> <atx> But to add more entrys
i would have to get rid of the atx, then use the fputs to place the new entry into the file. ....
How To Make A Random 7 Number Code?
(2) I am making a script in php, and for it I need to know how to make a random 7 digit code. I think it
has something to do with md5, but i am not sure. Thanks! EDIT- Can someone please change the
title to "How to make a random 7 digit code in php?" Thanks!....
Php Education Class (first Code)
(0) Hi I want to educate some PHP codes that i think they will be useful for all of you! My 1st
code is this: CODE <?php class calculator { /** * Variable for holding all
the numbers to add * * @var array */ private $numbers = array();
/** * Variable holding all the digits after the point * * @var array */
private $afterPoint = array(); /** * Maximum number of digits after
the point * that a number has * * @var int */ private $....
Ipetsite Related Programming Help Needed
iPetSite screwed me over (0) Ok so i you are anyone here who would like to hlp me with these files, please pm me your email. Here
is what i need help with: Replacement of lost files Repair of corrupt files Configuring said files
Help with setting up the site If you can help me, please let me know. If you would like to be an
admin on my site, also let me know. Just I request that you don't post here unless you plan or
intend to help some how.....
My Code Doesnt Resize Large Images, Please Help.
(2) Can someone please have a look at the following code, this uploads an image, and make it in 2 sizes,
one size is max. 600 x 800, uploads to images folder and second 120 x 120 and uploads to thumbs
folder. this script works fine, with normal size images, but if i try to upload large pics( for
example, an image with dimension 2432 x 3300, it shows blank page, and uploads the original image
without sizing to "image" folder, and doesnt make any small thumbnail... I hope u understand..
Please someone help me, i shall be so thankful. session_start(); header("Cache-contro....
Wap Source Code Viewer
Mobile/wap source code viewer page (4) This is a source code viewer that will workl on wap/mobile sites but you can easily convert it to
work on web im sure ;-) CODE <? header("Content-Type:
text/vnd.wap.wml"); echo '<?xml version="1.0"
encoding="utf-8"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <head><meta
http-equiv="Cache-Control" content="no-cache"
forua="true"/></head> <card title="s60.nerds.....
Dynamic Image / Signature Generator
a simple code to change text on an image (12) In search of dynamically changing quote, saying or all other types of text on an image I came across
a code that I have modified to fit my initial usage. This procedure requires two files and short
knowledge of PHP. If you are familiar with Trap17's sig rotation code you will understand this
procedure very fast. Code 1: dynamic_sig.php (you can rename this to index.php and you'll see
at the end why) Code 2: a simple text file named anything (I will call it name.txt ) Code 1
CODE <?php header("Content-type: image/png"); ....
Adapting Html Code Embed To Work On Phpnuke
Help With This Html Code Pls (7) QUOTE how can get this html code to work on my phpnuke site? what tags would i
have to enable in the $Allowable HTML part of my config.php file?? Edited topic title. Moved
to Programming. ....
Change Permission With Php Code
code to change files' and folders' permissions? (3) As everyone know, there two ways (that I can think of) to change files' and directories'
permissions. One is to change it in your cPanel's Disk Manager and the other is with an FTP
client that supports chmod. Well, I'm doing something for my site that requires files to have
full permissions (Execute, Write, and Read on all three groups). At first, I thought that if I made
the directory 777, then every file created in that directory will be 777 as well. I'm wrong. An
alternative to doing this is to change each file permission myself, but that would be....
Php Clock
source Code (7) Hi Every one i find this code its very easy simple php clock i think you can use it /blink.gif'
border='0' style='vertical-align:middle' alt='blink.gif' /> CODE <? // Binary Clock //
script copyright© 2002 Andreas Tscharnuter // questions? contact: psychodad@psychodad.at ||
[url=http://www.psychodad.at/clock/]http://www.psychodad.at/clock/[/url] //
free to use, copy and modify but leave comments untouched;) // just include this file where
your binary clock should appear // version 1.2 03 September 2003 // below you can ....
How do you test your php code
(75) 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)....
Looking for php, code, needed,
|
|
Searching Video's for php, code, needed,
|
advertisement
|
|