Jump to content

PHP & MYSQL


fm1

Recommended Posts

hi guys im noobie and very new to php, im trying to learn php on my own seeing that I dont have the funds to attend any lessons.

 

I need to create a webform, but firstly i need to create a table in mysql, im struggling for 2days now, how do i do this

 

what i done so far,

1. logged into mysql(obv)

2.created the database called members

 

what i need is a table called dbUsers

with the following fields:

username

password

verify password

email address

mobile

 

from there i need to access this database using a php script(dont know what to do here)

so that users can access the webform and fill in the details

 

any help on this guys

Link to comment
Share on other sites

wow...that's a lot of stuff.

 

To create a table, you just run this:

<?php
// change data below
mysql_connect("host_name","database_username","database_password");
mysql_select_db("database_name");

// you don't need verify_password to be honest
$tbl = "CREATE TABLE dbUsers(
username varchar(255) NOT NULL default '',
password varchar(32) default NULL,
verify_password varchar(32) default NULL,
email varchar(150) NOT NULL default '',
mobile varchar(11) default NULL
)";
mysql_query($tbl) or die(mysql_error());

?>

 

I don't know what you mean by accessing the database. What kind of webform?

Link to comment
Share on other sites

probably the easyest way to edit a database is using myphpadmin

 

it is a free download, and it is a good admin thing.

 

 

 

i have phpmyadmin but why would i need to edit the database if it was already created with the above table statement, all I need now is to publish this database in a php script so that it can be used

Link to comment
Share on other sites

that was a quick reply

 

you see, i need to able to open the form in a web browser, but obv in order to do that you need to compile a php script, what should my script look like

Well the server compiles a php script. ???

 

Um, just tell me what the form should do. For php files, you have to open it with <?php and close with ?>. The filename needs the extension .php

 

And what do you mean publish it?

 

Example please

Link to comment
Share on other sites

okay basically what i mean is , now that I got the databse created with the tables,the sql part is done, now i want to create a new php script, and when i open up that script in my browser the follwing script i created should open with the following fields to fill in and submit

 

username:

password:

verifypassword:

email address:

mobile:

 

then the visitor should type in their details and click submit, then those details should go to the admins email address, in other words its a web form whereby the data should be retrieved, stored,updated and editted by the mysql database members that I created earlier.

 

 

is this info im giving sounding dumb, if yes can you guys offer a better solution to the problem

Link to comment
Share on other sites

okay basically what i mean is , now that I got the databse created with the tables,the sql part is done, now i want to create a new php script, and when i open up that script in my browser the follwing script i created should open with the following fields to fill in and submit

 

username:

password:

verifypassword:

email address:

mobile:

 

then the visitor should type in their details and click submit, then those details should go to the admins email address, in other words its a web form whereby the data should be retrieved, stored,updated and editted by the mysql database members that I created earlier.

 

 

is this info im giving sounding dumb, if yes can you guys offer a better solution to the problem

 

Kinda a lot to ask but try this:

 

<?php

if (isset($_POST['submit'])){
$uname = mysql_escape_string($_POST['uname']);
$pass = mysql_escape_string($_POST['pass']);
$ver_pass = mysql_escape_string($_POST['vpass']);
$email = mysql_escape_string($_POST['email']);
$mobile = mysql_escape_string($_POST['mobile']);

if ($pass == $ver_pass){
// need help here. What should the message be?
$msg = "";
// edit in admin email
mail("admin_email", "subject", $msg);
}}

<form method='post'>
<input type='text' name='uname' /><br />
<input type='password' name='pass' /><br />
<input type='password' name='ver_pass' /><br />
<input type='text' name='email' /><br />
<input type='text' name='mobile' /><br />
<input type='submit' name='submit' value='submit' />
</form>
?>

Something like that?

Link to comment
Share on other sites

I see where you coming at but is this script somhow connected to the mysql database "members" ,this is the original project details if it might help, you script looks like a standlone form,am i wrong

 

Code an php web form . The form must accept and store a user's details. It must then retrieve/update/edit those details from the SQL DB and display it.

 

Some of the fields will include:

 

username

password

verify password

email address

mobile

 

Please note:

Validation is required on all fields

Access must be through stored procedures

No SQL allowed in code

Link to comment
Share on other sites

I see where you coming at but is this script somhow connected to the mysql database "members" ,this is the original project details if it might help, you script looks like a standlone form,am i wrong

 

Code an php web form . The form must accept and store a user's details. It must then retrieve/update/edit those details from the SQL DB and display it.

 

Some of the fields will include:

 

username

password

verify password

email address

mobile

 

Please note:

Validation is required on all fields

Access must be through stored procedures

No SQL allowed in code

Dude, unless you haven't noticed, this forum is for support. We don't write stuff for you. Read the guidelines. You can start something and ask for help, but asking us to write an entire system to your liking is against the rules.

 

I'm sorry, I didn't make the guidelines.

 

2. Don't ask someone to write or re-write a script for you, unless you are posting a message to the PHPFreelancing Forum.  The forums are not the place to request XYZ script.  This is a community of people learning PHP, and not a script location service.  Try searching sourceforge, phpclasses, hotscripts, or Google.

 

http://www.phpfreaks.com/forums/index.php/topic,6264.0.html

Link to comment
Share on other sites

I dont need you to write the whole script,i need guid lines,u didnt know what i meant so I posted what im trying to do,how do i recall the information from an sql databse i created so that its displayed as a form in the web webrowser,

Link to comment
Share on other sites

okay basically what i mean is , now that I got the databse created with the tables,the sql part is done, now i want to create a new php script, and when i open up that script in my browser the follwing script i created should open with the following fields to fill in and submit

 

username:

password:

verifypassword:

email address:

mobile:

 

then the visitor should type in their details and click submit, then those details should go to the admins email address, in other words its a web form whereby the data should be retrieved, stored,updated and editted by the mysql database members that I created earlier.

 

 

is this info im giving sounding dumb, if yes can you guys offer a better solution to the problem

 

Kinda a lot to ask but try this:

 

<?php

if (isset($_POST['submit'])){
$uname = mysql_escape_string($_POST['uname']);
$pass = mysql_escape_string($_POST['pass']);
$ver_pass = mysql_escape_string($_POST['vpass']);
$email = mysql_escape_string($_POST['email']);
$mobile = mysql_escape_string($_POST['mobile']);

if ($pass == $ver_pass){
// need help here. What should the message be?
$msg = "";
// edit in admin email
mail("admin_email", "subject", $msg);
}}

<form method='post'>
<input type='text' name='uname' /><br />
<input type='password' name='pass' /><br />
<input type='password' name='ver_pass' /><br />
<input type='text' name='email' /><br />
<input type='text' name='mobile' /><br />
<input type='submit' name='submit' value='submit' />
</form>
?>

Something like that?

 

with the above script results return syntax error in line 17

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.