I'm a PHP/mySQL guy but now I need to know how to connect to mySQL db using ASP and validate as some fields are required. The syntax is VERY different and after banging my head looking online for a bit of help, could the EE Gods plese help me.
Here is my form on an html page (not sure if it needs to be asp):
<form name="mailinglist" method="post" action="dbconn.asp">
<label for="fname">First Name:*</xxx>
<input type="text" id="fname" name="fname" maxlength="30" class="txtbox" /><br />
<label for="lname">Last Name:*</xx>
<input type="text" id="lname" name="lname" maxlength="30" class="txtbox" /><br />
<label for="add1">Address 1</label>
<input type="text" id="add1" name="add1" maxlength="80" class="txtbox" /><br />
<label for="add2">Address 2</xx>
<input type="text" id="add2" name="add2" maxlength="80" class="txtbox" /><br />
<label for="city">City:</label>
<input type="text" id="city" name="city" maxlength="30" class="txtbox" /><br />
<label for="state">State:</label>
<input type="text" id="state" name="state" maxlength="30" class="txtbox" /><br />
<label for="zip">Zip:*</label>
<input type="text" id="zip" name="zip" maxlength="5" class="txtbox" /><br />
<label for="add2">Email:*</label>
<input type="text" id="email" name="email" maxlength="80" class="txtbox" /><br />
<label for="phone">Telephone:</x>
<input type="text" id="phone" name="phone" maxlength="14" class="txtbox" /><br /><br />
<input type="image" name="submit" src="images/joinlist_submi
t.gif" class="img" />
<img class="img" src="images/joinlist_clear
.gif" onClick="javascript:docume
nt.mailing
list.reset
();return false">
</form>
on the dbconn.asp page i have:
<%
Dim sConnection, objConn , strSQL
Dim x_fname, x_lname, x_add1, x_add2, x_city, x_state, x_zip, x_email, x_phone
x_name = Request.Form("fname")
x_lname = Request.Form("lname")
x_add1 = Request.Form("add1")
x_add2 = Request.Form("add2")
x_city = Request.Form("city")
x_state = Request.Form("state")
x_zip = Request.Form("zip")
x_email = Request.Form("email")
x_phone = Request.Form("phone")
sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=xx.com; DATABASE=xx; UID=x;PASSWORD=xxxxx; OPTION=3"
Set objConn = Server.CreateObject("ADODB
.Connectio
n")
objConn.Open(sConnection)
strSQL = "INSERT INTO mailinglist (fname, lname, add1, add2, city, state, zip, email, phone) VALUES (???)"
objConn.Close
Set objConn = Nothing
%>
I need form validation to return an error message if fname, lname, zip and email are not filled, otherwise INSERT INTO mailinglist, redirect to Thankyou.html and have a nice day!
(Points set to 500 for urgency)
Thank you!
~Aus2Srq