connecting html form to php

A multipurpose module, plugin and component

connecting html form to php

New postby mark.thuroe » Tue Mar 04, 2014 3:07 am

I have the following form added to my joomla site with javascript to validate the form and it is working nicely. The bit that's not working so nice is that in the form tag i have an action to link to a php file that connects and adds my form details to a database i have created. My question is i dont no how to link my form to the php script in joomla. Im on the verge of pulling my hair out so a bit of help or a hint in the right direction would be greatly appreciated.
Code: Select all
<script type="text/javascript">
function validateForm()
{
var a=document.forms["reg"]["fname"].value;
var b=document.forms["reg"]["sname"].value;
var c=document.forms["reg"]["username"].value;
var d=document.forms["reg"]["email"].value;
var e=document.forms["reg"]["password"].value;
var f=document.forms["reg"]["password2"].value;

if ((a==null || a=="") && (b==null || b=="") && (c==null || c=="") && (d==null || d=="") && (e==null || e==""))
  {
  alert("All fields must be filled out");
  return false;
  }
if (a==null || a=="")
  {
  alert("First name must be filled out");
  return false;
  }
if (b==null || b=="")
  {
  alert("Second name must be filled out");
  return false;
  }
if (c==null || c=="")
  {
  alert("Username must be filled out");
  return false;
  }
if (d==null || d=="")
  {
  alert("email must be filled out");
  return false;
  }
if (e==null || e=="")
  {
  alert("Password must be filled out");
  return false;
  }
if (e != f)
  {
  alert("Passwords must be the same");
  return false;
  }
}
</script>



<form name="reg" action="code_exec.php" onsubmit="return validateForm()" method="post">
<table width="274" border="0" align="center" cellpadding="2" cellspacing="0">
 
  <tr>
    <td colspan="2">
      <div align="center">
      <?php
      $remarks=$_GET['remarks'];
      if ($remarks==null and $remarks=="")
      {
      echo '';
      }
      if ($remarks=='success')
      {
      echo 'Registration Success';
      }
      ?>   
       </div>
   </td>
  </tr>
  <tr>
    <td width="95"><div align="right">First Name:</div></td>
    <td width="171"><input type="text" name="fname" /></td>
  </tr>
  <tr>
    <td><div align="right">Second Name:</div></td>
    <td><input type="text" name="sname" /></td>
  </tr>
  <tr>
    <td><div align="right">Username:</div></td>
    <td><input type="text" name="username" /></td>
  </tr>
  <tr>
    <td><div align="right">Email:</div></td>
    <td><input type="email" name="email" /></td>
  </tr>
  <tr>
    <td><div align="right">Password:</div></td>
    <td><input type="password" name="password" /></td>
  </tr>
  <tr>
    <td><div align="right">Password:</div></td>
    <td><input type="password" name="password2" /></td>
  </tr>
  <tr>
    <td><div align="right"></div></td>
    <td><input name="submit" type="submit" value="Submit" /> <input name="reset" type="reset" value="Clear" /></td>
  </tr>
</table>
</form>
mark.thuroe
 
Posts: 1
Joined: Mon Mar 03, 2014 8:40 pm

Return to Jumi

Who is online

Users browsing this forum: No registered users and 6 guests

cron