Welcome Guest ( Log In | Register)



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Php Code, Needed?!
alex1985
post Feb 21 2008, 05:04 PM
Post #1


Super Member
*********

Group: [HOSTED]
Posts: 397
Joined: 9-February 08
Member No.: 57,615



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.
Go to the top of the page
 
+Quote Post
galexcd
post Feb 21 2008, 05:57 PM
Post #2


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,074
Joined: 25-September 05
From: Los Angeles, California
Member No.: 12,251



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.

This post has been edited by alex7h3pr0gr4m3r: Feb 21 2008, 05:59 PM
Go to the top of the page
 
+Quote Post
jlhaslip
post Feb 21 2008, 06:01 PM
Post #3


A computer once beat me at chess, but it was no match for me at kick boxing.
Group Icon

Group: [MODERATOR]
Posts: 4,085
Joined: 24-July 05
From: Linix, DOS and Windows…the good, the bad and the ugly
Member No.: 9,787
Spam Patrol



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.
Go to the top of the page
 
+Quote Post
alex1985
post Feb 21 2008, 09:59 PM
Post #4


Super Member
*********

Group: [HOSTED]
Posts: 397
Joined: 9-February 08
Member No.: 57,615



I wanna use like a login form, instead of username, you put the desired password.
Go to the top of the page
 
+Quote Post
shadowx
post Feb 21 2008, 10:12 PM
Post #5


A clever man learns from his own mistakes, a WISE man learns from those of OTHERS
***********

Group: [HOSTED]
Posts: 1,028
Joined: 12-April 06
From: Essex, UK
Member No.: 21,719



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 |


This post has been edited by shadowx: Feb 21 2008, 10:16 PM
Go to the top of the page
 
+Quote Post
galexcd
post Feb 21 2008, 10:45 PM
Post #6


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,074
Joined: 25-September 05
From: Los Angeles, California
Member No.: 12,251



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.

This post has been edited by alex7h3pr0gr4m3r: Feb 21 2008, 10:46 PM
Go to the top of the page
 
+Quote Post
alex1985
post Feb 22 2008, 11:45 AM
Post #7


Super Member
*********

Group: [HOSTED]
Posts: 397
Joined: 9-February 08
Member No.: 57,615



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!
Go to the top of the page
 
+Quote Post
galexcd
post Feb 23 2008, 01:29 AM
Post #8


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
***********

Group: [HOSTED]
Posts: 1,074
Joined: 25-September 05
From: Los Angeles, California
Member No.: 12,251



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?
Go to the top of the page
 
+Quote Post
alex1985
post Feb 23 2008, 09:27 AM
Post #9


Super Member
*********

Group: [HOSTED]
Posts: 397
Joined: 9-February 08
Member No.: 57,615



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?!