473,548 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Perl script to put user input to MySQL database

1 New Member
Hello i need some help with a script i am working on i have a mailserver and all users accounts are stored in a MySQL database.

I need to have a perl script that will take the user input and run the following database commands.

INSERT INTO domains (domain) VALUES ('example.com') ;
INSERT INTO users (email, password) VALUES ('sales@example .com', ENCRYPT('passwo rd'));

this is what i have so far

#!/usr/bin/perl -w
use strict;
use warnings FATAL => 'all';
use CGI;
use CGI::Carp qw(fatalsToBrow ser);
use DBI;
use DBD::mysql;

my $cgi = CGI->new;
print $cgi->header, $cgi->start_html;

my $domains = $cgi->param('domains ');
my $email = $cgi->param('email') ;
my $pasword = $cgi->param('passwor d');
my $database = "mail";
my $host = "localhost" ;
my $user = "user";
my $pw = "password";
my $dsn = "dbi:mysql:$dat abase:localhost :3306";
my $dbh = DBI->connect($dsn , $user, $pw,
{ RaiseError => 1 })
or die "unable to connect:$DBI::e rrstr\n";

my $query = "INSERT INTO domain (domain) VALUES (?,?)";
my $sth = $dbh->prepare($query );

$sth->execute($domai ns, $email);

# additional processing as needed ...

print $cgi->end_html;

any help is greatly apretiated
May 24 '17 #1
0 4439

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1519
by: hans | last post by:
Hello everybody, I was searching on "www.freshmeat.net", "www.hotscripts.com", etc. but I could not find anything. I am searching for a web based user-manager (php/perl, mysql) with one major feature: There is one login-screen (like the login at a provider) to enter the login-name and the password. If the user will log-in, he gets his
3
1411
by: Sammy | last post by:
What is the best script to use to back up and admin my mysql database? Tnanks, Sammy
1
3286
by: pizzy | last post by:
Problem: I am trying to develope my personal site to select from my mysql database and organize data on the page so that it will display all the submissions for that day, then break and display the next day, then break and display the third day, etc... Question:
14
6075
by: mistral | last post by:
Need php script to create mySQL database programmatically; since hosting configuration may not allow create database from script, script also need eliminate/rewrite all restrictions in appropriate places in that hosting.
5
1831
by: maverickx | last post by:
Hi everyone, i am a totally rookie in perl. I have a project which needs to use perl to connect to mysql database. I already installed the perl mysql driver, MySQL, and use perl code which i found on the internet to connect to the mysql database. However, it says the connection was denied. I didnt set username and password for the database. ...
4
3772
by: jane007 | last post by:
Hello everybody: I am having a problem. On Unix platform, there is a script that need user to input data from console, then when I call Unix perl script from Windows, these is an issue occurs, when I input data and enter "enter" so fast, the Windows console is freezed, I don't know why, does anybody know?Thank you very much. My code...
7
2259
by: Naira | last post by:
Dear all, Below here I show you a redirected page from a login.php where shows the results os the login session. This page will be once again redirected to an edit_user.php page. The question is how do I retrieve this loggedin user_id from the database. I have already tried GET_uid and many other forms of request without success. I...
3
1634
by: truptivk | last post by:
Hello all, I have written a simple PHP script that connects to a MySQL database and retrieves a record from a table. However, my script stop swith an error: 'Table yourdatabase.table does not exist', whereas it does! I see the table when I execute 'show tables;' and also when I 'desc' it. I can also run select queries on it from within the...
2
2211
by: tqa89 | last post by:
Hi, When user input the date,I want to save it to database. But I'm not sure about the date format,whether I should change the format? I'm using getter and setter method to save to database.I'm using db2 This is my code. DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); Date startDate=user.getDate_from();...
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7805
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5085
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1054
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.