How to covert a PHP form to submit to mysql database

Coverting a PHP form that submits to file to be able to submit to mysq

Page 1 of 1

1 Replies - 9970 Views - Last Post: 31 May 2007 - 06:01 PM Rate Topic: -----

#1 david4u  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 38
  • Joined: 26-April 06

How to covert a PHP form to submit to mysql database

Posted 31 May 2007 - 08:31 AM

Goodday,

I have written a php form that can submit data into a file but could not get it working to submit unto MYSQL database.

Can anyone help me on what to do to change the form now to be able to submit unto mysql database.

For example:

 <?php
$rand=rand("4567","7890");
$random=md5($rand);
$captcha= strtoupper(substr($random,0,4));
$hidden= "<input name='captcha' type='hidden' id='userlevel' value='$captcha'>";
echo <<<html
<head>
<title>USER REGISTRATION</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>User Registration</title>
<style>
TEXTAREA
{
FONT-SIZE: 10px;
FONT-FAMILY: Verdana;
}
SELECT
{
FONT-SIZE: 10px;
FONT-FAMILY: Verdana;
}
INPUT
{
FONT-SIZE: 10px;
FONT-FAMILY: Verdana;
}
.error
{
FONT-FAMILY: verdana;
font-size: 10px;
color: #FF0000;
}
.blktext, .blktext:link, .blktext:visited
{
FONT-FAMILY: verdana;
font-size: 10px;
color: #000000;
}
.blktext:hover
{
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #ff9900;
}
.logininput
{
border: 1px solid #ff9900;
WIDTH: 70px;
FONT-SIZE: 10px;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
}
</style>
</head>

<body>
<script>
function CheckAgree()
{
var x = document.forms["regform"].agree.checked;
if (x) return true;
alert("You must agree to Terms and Conditions to continue registration");
return false;
}
</script>

<form action="adduser.php" method="POST" name="regform" onsubmit="return CheckAgree();">
<div align="center">
<center>
<table>
<tr><td align="center" height="11" width="448">&nbsp;
<div align="left">
<table border="0" width="438">
<tbody><tr><td colspan="2" width="430">
<p align="center"><b><font size="3">User Management </font></b>&nbsp;</td></tr>
<tr>
<td class="blktext" align="right" width="121"><b>Username</b></td>
<td class="blktext" width="303">
<input value="" name="username">
<span class="error">*</span>
</td>
</tr>
<tr>
<td class="blktext" align="right" width="121"><b>Password</b></td>
<td class="blktext" width="303">
<input value="" name="password" type="password" size="20">
<span class="error">*</span>
</td>
</tr>
<tr>
<td class="blktext" align="right" width="121"><b>Confirm Password</b></td>
<td class="blktext" width="303">
<input value="" name="retype" type="password" size="20">
<span class="error">*</span>
</td>
</tr>
<tr>
<td class="blktext" align="right" width="121"><b>Email address</b></td>
<td class="blktext" width="303">
<input value="" name="email">
<span class="error">* <b>(Valid email)</b></span>
</td>
</tr> 



What do I need to do to be able to submit it into mysql database

[mod edit] added/fixed code tags

This post has been edited by hotsnoj: 31 May 2007 - 08:31 PM


Is This A Good Question/Topic? 0
  • +

Replies To: How to covert a PHP form to submit to mysql database

#2 Styx  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 192
  • Joined: 04-March 07

Re: How to covert a PHP form to submit to mysql database

Posted 31 May 2007 - 06:01 PM

Probably somewhere near the top, you can put a check if the form has been submitted, maybe by checking the name of the submit button or checking the request type. Inside, you can perform your form checking then, if all is good, submit it to the database. See this page to learn about the various mysql functions if you don't know already.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1