Jump to content

[SOLVED] First Reg code - close but...


Hafoc

Recommended Posts

Hi,

This is not my 1st php code, but my first registration/membership code.

I used PHP Designer to debug and have found and cleaned what I can. But I have been hitting this wall all week. This is for a non-profit

 

http://www.herndonalliance.org/HA2/HA3/AHAdata/partnersRegister.php

 

I totally need help!! Thanks!

 

Hafoc

 

<?php

 

// Check if the form has been submitted

if (isset($_POST['submit'])) { // Handle the form

 

require_once('../../../Connections/regconnection.php');  // Connect to the db

 

// Create a function for escaping the data

function escape_data ($data) {

global $dbc; // Need the connection

if (ini_get('magic_quotes_gpc')) {

$data = stripslashes($data);

}

return mysql_real_escape_string(trim($data), $dbc);

} // End of function

 

$errors = array(); // Initialize error array

 

// Check for a password and match against the confirmed password

if (!empty($_POST['password'])) {

if ($_POST['password'] != $_POST['confirmpassword']) {

$errors[] = 'Your password did not match the confirmed password.';

} else {

$_POST['password'] = escape_data($_POST['password']);

}

} else {

$errors[] = 'You forgot to enter your password.';

}

 

// Make sure the email address is available

$query = "SELECT email FROM partners WHERE email='$_POST'";

$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

 

if (mysql_num_rows($result) == 0) { // Available

 

// Add the user.

$query = "INSERT INTO partners (lastName, firstName, Organization, address, city, state, zip, OrganizationTypeBusiness, OrganizationTypeHealthA, OrganizationTypeFaith, OrganizationTypeProvider, OrganizationTypeLabor, OrganizationTypeOther, Email, password, confirmPassword, Phone, Fax, HowHearUsCo, HowHearUsWeb, HowHearUsRadio, HowHearUsTV, HowHearUsPrint, HowHearUsOther, notListed) VALUES ('$_POST[last]','$_POST[first]','$_POST[organization]','$_POST[orgaddress]','$_POST[orgcity]','$_POST[orgstate]','$_POST[orgzip]','$_POST[orgtypebusiness]','$_POST[orgtypehealth]','$_POST[orgtypefaith]','$_POST[orgtypeprovider]','$_POST[orgtypelabor]','$_POST[other]','$_POST','$_POST[password]','$_POST[confirmpassword]','$_POST[tele]','$_POST[fax]','$_POST[howcoworker]','$_POST[howweb]','$_POST[howradio]','$_POST[howtv]','$_POST[howprint]','$_POST[howother]','$_POST[pubyes]')";

$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

 

if (mysql_affected_rows() == 1) { // If it ran OK.

 

// Send the email

$body = "Thank you for becoming a partner with Herndon Alliance. This is an automated response, please do not reply to this letter.";

mail ($_POST['email'], 'Thank you for registering', $body, 'From: hafocz@gmail.com');

 

$body = "HA has a new partner";

mail ('hafocz@gmail.com', 'HA new partner', $body, 'From: hafocz@gmail.com');

 

 

} else { // If it did not run OK

echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';

}

 

} else { // The email address is not available

echo '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password, use the link to have your password sent to you.</font></p>';

}

 

} else { // If one of the data tests failed

echo '<p><font color="red" size="+1">Please try again.</font></p>';

 

}

mysql_close(); // Close the database connection.

// End of the main Submit conditional

?>

 

Link to comment
Share on other sites

OK it looks like

 

if (mysql_affected_rows() == 1) { // If it ran OK.

 

// Send the email

$body = "Thank you for becoming a partner with Herndon Alliance. This is an automated response, please do not reply to this letter.";

mail ($_POST['email'], 'Thank you for registering', $body, 'From: hafocz@gmail.com');

 

$body = "HA has a new partner";

mail ('hafocz@gmail.com', 'HA new partner', $body, 'From: hafocz@gmail.com');

 

} else if { // If it did not run OK

echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';

}

 

} else if { // The email address is not available

echo '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password, use the link to have your password sent to you.</font></p>';

}

 

    } else { // If one of the data tests failed

echo '<p><font color="red" size="+1">Please try again.</font></p>';

        }

 

and now I get the error

PHP Parse error: syntax error, unexpected '{' expecting '(' (I bold/red the line it)

 

 

Link to comment
Share on other sites

darkfreaks, I don't think the structure is the problem here.......

 

Hafoc, if you could try this code:

<?php
if ($_POST['submit'] == TRUE)
{
	require_once('../../../Connections/regconnection.php');  // Connect to the db

	// Create a function for escaping the data
	function escape_data ($data)
	{
		global $dbc; // Need the connection

		if (ini_get('magic_quotes_gpc'))
		{
			$data = stripslashes($data);
		}
		return mysql_real_escape_string(trim($data), $dbc);
	} // End of function

	$errors = array(); // Initialize error array

	// Check for a password and match against the confirmed password
	if ($_POST['password'] == TRUE)
	{
		if ($_POST['password'] != $_POST['confirmpassword'])
		{
			$errors[] = 'Your password did not match the confirmed password.';
		}
		else
		{
			$_POST['password'] = escape_data($_POST['password']);
		}
	}
	else
	{
		$errors[] = 'You forgot to enter your password.';
	}

	// Make sure the email address is available
	$query = "SELECT email FROM partners WHERE email='". $_POST['email'] ."'";
	$result = mysql_query($query) or trigger_error("Query: ". $query ."\n MySQL Error: ". mysql_error());

	if (mysql_num_rows($result) == 0)
	{ // Available

		// Add the user.
		$query = "INSERT INTO partners (lastName, firstName, Organization, address, city, state, zip, OrganizationTypeBusiness, OrganizationTypeHealthA, OrganizationTypeFaith, OrganizationTypeProvider, OrganizationTypeLabor, OrganizationTypeOther, Email, password, confirmPassword, Phone, Fax, HowHearUsCo, HowHearUsWeb, HowHearUsRadio, HowHearUsTV, HowHearUsPrint, HowHearUsOther, notListed) VALUES ('". $_POST['last'] ."','". $_POST['first'] ."','". $_POST['organization'] ."','". $_POST['orgaddress'] ."','". $_POST['orgcity'] ."','". $_POST['orgstate'] ."','". $_POST['orgzip'] ."','". $_POST['orgtypebusiness'] ."','". $_POST['orgtypehealth'] ."','". $_POST['orgtypefaith'] ."','". $_POST['orgtypeprovider'] ."','". $_POST['orgtypelabor'] ."','". $_POST['other'] ."','". $_POST['email'] ."','". $_POST['password'] ."','". $_POST['confirmpassword'] ."','". $_POST['tele'] ."','". $_POST['fax'] ."','". $_POST['howcoworker'] ."','". $_POST['howweb'] ."','". $_POST['howradio'] ."','". $_POST['howtv'] ."','". $_POST['howprint'] ."','". $_POST['howother'] ."','". $_POST['pubyes'] ."')";
		$result = mysql_query ($query) or trigger_error("Query: $query\n
		MySQL Error: " . mysql_error());

		if (mysql_affected_rows() == 1)
		{ // If it ran OK.

			// Send the email
			$body = "Thank you for becoming a partner with Herndon Alliance. This is an automated response, please do not reply to this letter.";
			mail ($_POST['email'], 'Thank you for registering', $body, 'From: hafocz@gmail.com');

			$body = "HA has a new partner";
			mail ('hafocz@gmail.com', 'HA new partner', $body, 'From: hafocz@gmail.com');
		}
		else
		{ // If it did not run OK
			echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';
		}
	}
	else
	{ // The email address is not available
		echo '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password, use the link to have your password sent to you.</font></p>';
	}
}
else
{
	echo '<p><font color="red" size="+1">Please try again.</font></p>';
}

mysql_close(); // Close the database connection.
	// End of the main Submit conditional
?>

I've made a few modifications with the if (isset($_POTS[])). I've ran into many problems doing it that way.

 

 

Also, keep in mind, it is far safer for your users if you encrypt their passwords before you add it into the database!

 

It is also safer for you not to add user input directly into your query.

 

 

Link to comment
Share on other sites

OK now I am getting a >

else

{ // If it did not run OK

echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';

}

>

 

The new code and advice is great help, is it something in the insert? This is causing me to go crazy!

Link to comment
Share on other sites

To BobLeny:

OK, in the Browser I entered some test data, submitted and returned

 

 

INSERT INTO partners (lastName, firstName, Organization, address, city, state, zip, OrganizationTypeBusiness, OrganizationTypeHealthA, OrganizationTypeFaith, OrganizationTypeProvider, OrganizationTypeLabor, OrganizationTypeOther, Email, password, confirmPassword, Phone, Fax, HowHearUsCo, HowHearUsWeb, HowHearUsRadio, HowHearUsTV, HowHearUsPrint, HowHearUsOther, notListed) VALUES ('Test','Test','None','111 Test','Seattle','WA','981-9','','','','','','checkbox','earthlydiva@earthlink.net','','test','206.111.12','None','','checkbox','','','','','checkbox')

 

To DarkFreaks

The code is not inserting the form data into the database. The connection is good, I just cannot seem to get the insert to happen.

 

Hafoc

Link to comment
Share on other sites

Take a look at this here:

VALUES ('Test','Test','None','111 Test','Seattle','WA','981-9','','','','','','checkbox','earthlydiva@earthlink.net','','test','206.111.12','None','','checkbox','','','','','checkbox')

 

You see all the '', ? Nothing is there. This either means you didn't enter anything in those fields or the variables aren't named right.....

 

 

 

Try this real quick as well:

Change what you have to this:

// Add the user.

$query = "INSERT INTO partners (lastName, firstName, Organization, address, city, state, zip, OrganizationTypeBusiness, OrganizationTypeHealthA, OrganizationTypeFaith, OrganizationTypeProvider, OrganizationTypeLabor, OrganizationTypeOther, Email, password, confirmPassword, Phone, Fax, HowHearUsCo, HowHearUsWeb, HowHearUsRadio, HowHearUsTV, HowHearUsPrint, HowHearUsOther, notListed) VALUES ('". $_POST['last'] ."','". $_POST['first'] ."','". $_POST['organization'] ."','". $_POST['orgaddress'] ."','". $_POST['orgcity'] ."','". $_POST['orgstate'] ."','". $_POST['orgzip'] ."','". $_POST['orgtypebusiness'] ."','". $_POST['orgtypehealth'] ."','". $_POST['orgtypefaith'] ."','". $_POST['orgtypeprovider'] ."','". $_POST['orgtypelabor'] ."','". $_POST['other'] ."','". $_POST['email'] ."','". $_POST['password'] ."','". $_POST['confirmpassword'] ."','". $_POST['tele'] ."','". $_POST['fax'] ."','". $_POST['howcoworker'] ."','". $_POST['howweb'] ."','". $_POST['howradio'] ."','". $_POST['howtv'] ."','". $_POST['howprint'] ."','". $_POST['howother'] ."','". $_POST['pubyes'] ."')";
$result = mysql_query ($query) or Die(mysql_error());

 

Then report the error that is echoed.

Link to comment
Share on other sites

<?php

# FileName="Connection_php_mysql.htm"

# Type="MYSQL"

# HTTP="true"

$hostname_regconnection = "db47int.dotsterhost.com";

$database_regconnection = "db100162_HAreg";

$username_regconnection = "u100162_herndon";

$password_regconnection = "editedOut";

$regconnection = mysql_pconnect($hostname_regconnection, $username_regconnection, $password_regconnection) or trigger_error(mysql_error(),E_USER_ERROR);

?>

 

I ran a connection test and (from the book) received that there was a connection

 

<?php

echo mysql_connect ('db47int.dotsterhost.com','u100162_herndon','editout');

 

?>

Link to comment
Share on other sites

Very good. Once you connect, you then need to select a database.

 

This is what I personally use:

$database_select_1 = //the name of the table being used ;
$selectdb = mysql_select_db("$database_select_1");
if(!$selectdb)
{
//If it can't select the table, report an error
}

 

You can do this once in your connection script, so long as you only need to input and withdraw data from the one table.

Link to comment
Share on other sites

OK, I wrote that last message wrong -- I went back to the last code we tried not the original

 

after I submit the test data I get a blank page

 

In your code

 

$database_select_1 = partners;  

 

or 'partners';

 

//the name of the table being used

$selectdb = mysql_select_db("$database_select_1");

if(!$selectdb)

{

//If it can't select the table, report an error

}

Link to comment
Share on other sites

OK

 

HTML/PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

 

<!-- start head tag -->

<head>

<title>Herndon Alliance - Partner Registration</title> 

<!-- start Script -->

<!-- Javascript for copyright date-->

<script src="../../javaScripts/newDate.js"  type="text/javascript"></script>

 

<?php

if ($_POST['submit'] == TRUE)

{

require_once('../../Connections/regconnection.php');  // Connect to the db

 

// Create a function for escaping the data

function escape_data ($data)

{

global $dbc; // Need the connection

 

if (ini_get('magic_quotes_gpc'))

{

$data = stripslashes($data);

}

return mysql_real_escape_string(trim($data), $dbc);

} // End of function

 

$errors = array(); // Initialize error array

 

// Check for a password and match against the confirmed password

if ($_POST['password'] == TRUE)

{

if ($_POST['password'] != $_POST['confirmpassword'])

{

$errors[] = 'Your password did not match the confirmed password.';

}

else

{

$_POST['password'] = escape_data($_POST['password']);

}

}

else

{

$errors[] = 'You forgot to enter your password.';

}

 

// Make sure the email address is available

$query = "SELECT email FROM partners WHERE email='". $_POST['email'] ."'";

$result = mysql_query($query) or trigger_error("Query: ". $query ."\n MySQL Error: ". mysql_error());

 

if (mysql_num_rows($result) == 0)

{ // Available

 

// Add the user.

$query = "INSERT INTO partners (lastName, firstName, Organization, address, city, state, zip, OrganizationTypeBusiness, OrganizationTypeHealthA, OrganizationTypeFaith, OrganizationTypeProvider, OrganizationTypeLabor, OrganizationTypeOther, Email, password, confirmPassword, Phone, Fax, HowHearUsCo, HowHearUsWeb, HowHearUsRadio, HowHearUsTV, HowHearUsPrint, HowHearUsOther, notListed) VALUES ('". $_POST['last'] ."','". $_POST['first'] ."','". $_POST['organization'] ."','". $_POST['orgaddress'] ."','". $_POST['orgcity'] ."','". $_POST['orgstate'] ."','". $_POST['orgzip'] ."','". $_POST['orgtypebusiness'] ."','". $_POST['orgtypehealth'] ."','". $_POST['orgtypefaith'] ."','". $_POST['orgtypeprovider'] ."','". $_POST['orgtypelabor'] ."','". $_POST['other'] ."','". $_POST['email'] ."','". $_POST['password'] ."','". $_POST['confirmpassword'] ."','". $_POST['tele'] ."','". $_POST['fax'] ."','". $_POST['howcoworker'] ."','". $_POST['howweb'] ."','". $_POST['howradio'] ."','". $_POST['howtv'] ."','". $_POST['howprint'] ."','". $_POST['howother'] ."','". $_POST['pubyes'] ."')";

$result = mysql_query ($query) or trigger_error("Query: $query\n

MySQL Error: " . mysql_error());

 

if (mysql_affected_rows() == 1)

{ // If it ran OK.

 

// Send the email

$body = "Thank you for becoming a partner with Herndon Alliance. This is an automated response, please do not reply to this letter.";

mail ($_POST['email'], 'Thank you for registering', $body, 'From: hafocz@gmail.com');

 

$body = "HA has a new partner";

mail ('hafocz@gmail.com', 'HA new partner', $body, 'From: hafocz@gmail.com');

exit();

}

else

{ // If it did not run OK

echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';

}

}

else

{ // The email address is not available

echo '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password, use the link to have your password sent to you.</font></p>';

}

}

 

mysql_close(); // Close the database connection.

// End of the main Submit conditional

?>

 

 

<link href="../../cssScripts/member.css" rel="stylesheet" type="text/css" />

<style type="text/css">

<!--

.style1 {font-size: 12px}

-->

</style>

 

</head>

<!-- end head tag -->

 

<!-- begin body -->

<body>

 

<!-- Start main for middle background-->

<div id="main">

 

<!-- start header image-->

<div id="header">

<img src="../../images/imagesSidePages/headerMembers.jpg" alt="Logo" /></div>

<!--end header -->

 

<!--start content -->

<div id="content">

  <h1> </h1>

<!--start content here to keep spacing-->

  <h1>Register to become a Partner</h1>

  <p>By submitting this form organizations and individuals commit to be a partner in the Alliance.  A partner is supportive of the Herndon Alliance values statement and work plan and:</p>

  <p>1.  Selects the coordination committee that will guide the work of the Alliance.

    <br />

    2.  Provides input into the work of the Alliance.

    <br />

    3.  Considers the messaging and initiatives identified by the Herndon Alliance for the use by member's organization.</p>

  <p>All fields marked * are required </p>

 

  <form action="partnersRegister.php"  method="POST">

    <table width="100%" border="0" cellspacing="10" cellpadding="5">

    <tr>

      <td><p><strong>Name* </strong>

          <label>First

          <input name="first" type="text" size="31" maxlength="20" value="<?php if (isset($_POST['first'])) echo $_POST['first']; ?>"/> </label>

        <label>Last 

        <input name="last" type="text" size="33" maxlength="20" value="<?php if (isset($_POST['last'])) echo $_POST['last']; ?>" /> </label>  </p></td>

    </tr>

    <tr>

      <td><p><label><strong>Email Address*</strong>

          <input name="email" type="text" size="71" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></label>

        <br />

        Your Email address will be your login</p></td>

    </tr>

    <tr>

      <td height="42"><p><label><strong>Password*</strong>

          <input name="password" type="password" size="20" maxlength="15" />

          </label>

          <label>Confirm Password*

          <input name="confirmpassword" type="password" size="26" maxlength="15" />

      </label>

          <br />

          <span class="style1">Use only letters and numbers. Must be between 4 and 20 characters long.</span></p></td>

    </tr>

    <tr>

      <td><p>

        <label><strong>Organization</strong>

          <input name="organization" type="text" value="None" size="74" maxlength="50" />

        </label></p></td>

    </tr>

    <tr>

      <td><p>

        <label><strong>Address*</strong>

          <input name="orgaddress" type="text" size="79" maxlength="65" value="<?php if (isset($_POST['orgaddress'])) echo $_POST['orgaddress']; ?>" />

        </label>

      </p></td>

    </tr>

    <tr>

      <td><p>

        <label><strong>City*</strong>

          <input name="orgcity" type="text" size="40" maxlength="30" value="<?php if (isset($_POST['orgcity'])) echo $_POST['orgcity']; ?>" />

        </label>

          <label><strong>State</strong>*

      <input name="orgstate" type="text" size="6" maxlength="2" value="<?php if (isset($_POST['orgstate'])) echo $_POST['orgstate']; ?>" />

          </label>

      <label><strong>Zip</strong>*

      <input name="orgzip" type="text" size="11" maxlength="10" value="<?php if (isset($_POST['orgzip'])) echo $_POST['orgzip']; ?>" />

      </label>

      </p></td>

    </tr>

    <tr>

      <td><p><label><strong>Telephone*</strong>

          <input name="tele" type="text" size="20" maxlength="10" value="<?php if (isset($_POST['tele'])) echo $_POST['tele']; ?>" />

      </label>

          Fax

          <label><input name="fax" type="text" value="None" size="20" maxlength="10"  />

          </label>

      </p></td>

    </tr>

    <tr>

      <td><p>

        <label><strong>Organization Type </strong>(check all that apply)<strong>:<br />

        </strong>

            <input type="checkbox" name="orgtypebusiness" value="checkbox" />

        Business</label>

          <label>

          <input type="checkbox" name="orgtypehealth" value="checkbox" />

          Health Advocacy</label>

          <label>

          <input type="checkbox" name="orgtypefaith" value="checkbox" />

          Faith</label>

          <br />

          <label>

          <input type="checkbox" name="orgtypeprovider" value="checkbox" />

          Provider</label>

          <label>

          <input type="checkbox" name="orgtypelabor" value="checkbox" />

          Labor</label>

          <label>

          <input type="checkbox" name="other" value="checkbox" />

          Other</label>

          <br />

      </p> </td>

    </tr>

    <tr>

      <td><p><strong>How did you hear about us?</strong> (check all that apply)<br />

          <label>

            <input type="checkbox" name="howcoworker" value="checkbox" />

            Co-worker</label>

              <label>

              <input type="checkbox" name="howweb" value="checkbox" />

              Web</label>

              <label>

              <input type="checkbox" name="howradio" value="checkbox" />

              Radio</label>

              <label>

              <input type="checkbox" name="howtv" value="checkbox" />

              TV</label>

              <label>

              <input type="checkbox" name="howprint" value="checkbox" />

              Print Ad</label>

              <label>

              <input type="checkbox" name="howother" value="checkbox" />

              Other</label>

        <br />

      </p></td>

    </tr>

    <tr>

      <td>Do you want your organization listed or published as a Herndon Alliance Partner.<br />

        <label>Yes

        <input type="checkbox" name="pubyes" value="checkbox" /></label>

        <label>No

        <input type="checkbox" name="pubno" value="checkbox" />

        </label></td>

    </tr>

    <tr>

      <td><input name="submit" type="submit" onclick="MM_validateForm('first','','R','last','','R','email','','RisEmail','orgaddress','','R','orgcity','','R','orgstate','','R','orgzip','','R','tele','','R','password','','R','confirmpassword','','R');return document.MM_returnValue" value="Register" />

<input type="hidden" name="submitted" value="TRUE" />

<input type="hidden" name="redirect" value="http://herndonalliance.org/HA2/HA3/AHAdata/partnersThanks.php" />

      Return <a href="../../index.php">Home </a></td>

    </tr>

  </table>

  </form>

  <p> </p>

 

</div>

<!--end content-->

<!-- Begin Clear For code use Do Not add content here!-->

  <div id="clear"> <p> </p> </div>

<!-- End Clear -->

<!-- Start Footer-->

<div id="footer">

<!-- Insert footer -->

<?php

include('../../lbi/footer.lbi');

?>

</div>

<!-- End Footer -->

<!-- End main -->

</div>

<!-- End Body -->

</body>

<!--bye bye Hafoc Yates hafoc.org 2007 -->

</html>

 

 

Connection PHP

 

<?php

# FileName="Connection_php_mysql.htm"

# Type="MYSQL"

# HTTP="true"

$hostname_regconnection = "db47int.dotsterhost.com";

$database_regconnection = "db100162_HAreg";

$username_regconnection = "u100162_herndon";

$password_regconnection = "zzz";

$regconnection = mysql_pconnect($hostname_regconnection, $username_regconnection, $password_regconnection) or trigger_error(mysql_error(),E_USER_ERROR);

 

$database_select_1 = "partners"; //the name of the table being used

$selectdb = mysql_select_db("$database_select_1");

if(!$selectdb)

{

//If it can't select the table, report an error

}

?>

Link to comment
Share on other sites

Trying to learn how to reply correctly

OK, this is easier to read. Sorry for the messy last message.

 

 

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_regconnection = "db47int.dotsterhost.com";
$database_regconnection = "db1001628_HAreg";
$username_regconnection = "u1001628_herndon";
$password_regconnection = "seadragon";
$regconnection = mysql_pconnect($hostname_regconnection, $username_regconnection, $password_regconnection) or trigger_error(mysql_error(),E_USER_ERROR); 

$database_select_1 = "partners"; //the name of the table being used 
$selectdb = mysql_select_db("$database_select_1");
if(!$selectdb)
{

}
?>

 

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!-- start head tag -->
<head>
<title>Herndon Alliance - Partner Registration</title>   
<!-- start Script -->
<!-- Javascript for copyright date-->
<script src="../../javaScripts/newDate.js"  type="text/javascript"></script>

<?php
if ($_POST['submit'] == TRUE)
{
	require_once('../../Connections/regconnection.php');  // Connect to the db

	// Create a function for escaping the data
	function escape_data ($data)
	{
		global $dbc; // Need the connection

		if (ini_get('magic_quotes_gpc'))
		{
			$data = stripslashes($data);
		}
		return mysql_real_escape_string(trim($data), $dbc);
	} // End of function

	$errors = array(); // Initialize error array

	// Check for a password and match against the confirmed password
	if ($_POST['password'] == TRUE)
	{
		if ($_POST['password'] != $_POST['confirmpassword'])
		{
			$errors[] = 'Your password did not match the confirmed password.';
		}
		else
		{
			$_POST['password'] = escape_data($_POST['password']);
		}
	}
	else
	{
		$errors[] = 'You forgot to enter your password.';
	}

	// Make sure the email address is available
	$query = "SELECT email FROM partners WHERE email='". $_POST['email'] ."'";
	$result = mysql_query($query) or trigger_error("Query: ". $query ."\n MySQL Error: ". mysql_error());

	if (mysql_num_rows($result) == 0)
	{ // Available

		// Add the user.
		$query = "INSERT INTO partners (lastName, firstName, Organization, address, city, state, zip, OrganizationTypeBusiness, OrganizationTypeHealthA, OrganizationTypeFaith, OrganizationTypeProvider, OrganizationTypeLabor, OrganizationTypeOther, Email, password, confirmPassword, Phone, Fax, HowHearUsCo, HowHearUsWeb, HowHearUsRadio, HowHearUsTV, HowHearUsPrint, HowHearUsOther, notListed) VALUES ('". $_POST['last'] ."','". $_POST['first'] ."','". $_POST['organization'] ."','". $_POST['orgaddress'] ."','". $_POST['orgcity'] ."','". $_POST['orgstate'] ."','". $_POST['orgzip'] ."','". $_POST['orgtypebusiness'] ."','". $_POST['orgtypehealth'] ."','". $_POST['orgtypefaith'] ."','". $_POST['orgtypeprovider'] ."','". $_POST['orgtypelabor'] ."','". $_POST['other'] ."','". $_POST['email'] ."','". $_POST['password'] ."','". $_POST['confirmpassword'] ."','". $_POST['tele'] ."','". $_POST['fax'] ."','". $_POST['howcoworker'] ."','". $_POST['howweb'] ."','". $_POST['howradio'] ."','". $_POST['howtv'] ."','". $_POST['howprint'] ."','". $_POST['howother'] ."','". $_POST['pubyes'] ."')";
		$result = mysql_query ($query) or trigger_error("Query: $query\n
		MySQL Error: " . mysql_error());

		if (mysql_affected_rows() == 1)
		{ // If it ran OK.

			// Send the email
			$body = "Thank you for becoming a partner with Herndon Alliance. This is an automated response, please do not reply to this letter.";
			mail ($_POST['email'], 'Thank you for registering', $body, 'From: hafocz@gmail.com');

			$body = "HA has a new partner";
			mail ('hafocz@gmail.com', 'HA new partner', $body, 'From: hafocz@gmail.com');
			exit();		
		}
		else 
		{ // If it did not run OK
			echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';
		}
	}
	else 
	{ // The email address is not available
		echo '<p><font color="red" size="+1">That email address has already been registered. If you have forgotten your password, use the link to have your password sent to you.</font></p>';
	}
}

mysql_close(); // Close the database connection.
	// End of the main Submit conditional
?>


<link href="../../cssScripts/member.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-size: 12px}
-->
</style>

</head>
<!-- end head tag -->

<!-- begin body -->
<body>

<!-- Start main for middle background-->
<div id="main">

<!-- start header image-->
<div id="header">
<img src="../../images/imagesSidePages/headerMembers.jpg" alt="Logo" /></div>	
<!--end header -->

<!--start content -->
<div id="content">
  <h1> </h1>
<!--start content here to keep spacing-->
  <h1>Register to become a Partner</h1>
  <p>By submitting this form organizations and individuals commit to be a partner in the Alliance.  A partner is supportive of the Herndon Alliance values statement and work plan and:</p>
  <p>1.  Selects the coordination committee that will guide the work of the Alliance.
    <br />
    2.  Provides input into the work of the Alliance.
    <br />
    3.  Considers the messaging and initiatives identified by the Herndon Alliance for the use by member's organization.</p>
  <p>All fields marked * are required </p>

  <form action="partnersRegister.php"  method="POST">
    <table width="100%" border="0" cellspacing="10" cellpadding="5">
    <tr>
      <td><p><strong>Name* </strong> 
          <label>First 
          <input name="first" type="text" size="31" maxlength="20" value="<?php if (isset($_POST['first'])) echo $_POST['first']; ?>"/> </label>
        <label>Last 
        <input name="last" type="text" size="33" maxlength="20" value="<?php if (isset($_POST['last'])) echo $_POST['last']; ?>" /> </label>  </p></td>
    </tr>
    <tr>
      <td><p><label><strong>Email Address*</strong>
          <input name="email" type="text" size="71" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></label>
        <br />
        Your Email address will be your login</p></td>
    </tr>
    <tr>
      <td height="42"><p><label><strong>Password*</strong>
          <input name="password" type="password" size="20" maxlength="15" /> 
          </label>
          <label>Confirm Password* 
          <input name="confirmpassword" type="password" size="26" maxlength="15" />
      </label>
          <br />
          <span class="style1">Use only letters and numbers. Must be between 4 and 20 characters long.</span></p></td>
    </tr>
    <tr>
      <td><p>
        <label><strong>Organization</strong>
          <input name="organization" type="text" value="None" size="74" maxlength="50" />
        </label></p></td>
    </tr>
    <tr>
      <td><p>
        <label><strong>Address*</strong>
          <input name="orgaddress" type="text" size="79" maxlength="65" value="<?php if (isset($_POST['orgaddress'])) echo $_POST['orgaddress']; ?>" />
        </label>
      </p></td>
    </tr>
    <tr>
      <td><p>
        <label><strong>City*</strong>
          <input name="orgcity" type="text" size="40" maxlength="30" value="<?php if (isset($_POST['orgcity'])) echo $_POST['orgcity']; ?>" />
        </label>
          <label><strong>State</strong>*
      <input name="orgstate" type="text" size="6" maxlength="2" value="<?php if (isset($_POST['orgstate'])) echo $_POST['orgstate']; ?>" />
          </label>
      <label><strong>Zip</strong>*
      <input name="orgzip" type="text" size="11" maxlength="10" value="<?php if (isset($_POST['orgzip'])) echo $_POST['orgzip']; ?>" />
      </label>
      </p></td>
    </tr>
    <tr>
      <td><p><label><strong>Telephone*</strong>
          <input name="tele" type="text" size="20" maxlength="10" value="<?php if (isset($_POST['tele'])) echo $_POST['tele']; ?>" />
      </label>
          Fax
          <label><input name="fax" type="text" value="None" size="20" maxlength="10"  />
          </label>
      </p></td>
    </tr>
    <tr>
      <td><p>
        <label><strong>Organization Type </strong>(check all that apply)<strong>:<br />
        </strong>
            <input type="checkbox" name="orgtypebusiness" value="checkbox" />
        Business</label> 
          <label>
          <input type="checkbox" name="orgtypehealth" value="checkbox" />
          Health Advocacy</label>
          <label>
          <input type="checkbox" name="orgtypefaith" value="checkbox" />
          Faith</label>
          <br />
          <label>
          <input type="checkbox" name="orgtypeprovider" value="checkbox" />
          Provider</label>
          <label>
          <input type="checkbox" name="orgtypelabor" value="checkbox" />
          Labor</label>
          <label>
          <input type="checkbox" name="other" value="checkbox" />
          Other</label>
          <br />
      </p> </td>
    </tr>
    <tr>
      <td><p><strong>How did you hear about us?</strong> (check all that apply)<br />
          <label>
            <input type="checkbox" name="howcoworker" value="checkbox" />
            Co-worker</label>
              <label>
              <input type="checkbox" name="howweb" value="checkbox" />
              Web</label>
              <label>
              <input type="checkbox" name="howradio" value="checkbox" />
              Radio</label>
              <label>
              <input type="checkbox" name="howtv" value="checkbox" />
              TV</label>
              <label>
              <input type="checkbox" name="howprint" value="checkbox" />
              Print Ad</label>
              <label>
              <input type="checkbox" name="howother" value="checkbox" />
              Other</label>
        <br />
      </p></td>
    </tr>
    <tr>
      <td>Do you want your organization listed or published as a Herndon Alliance Partner.<br />
        <label>Yes
        <input type="checkbox" name="pubyes" value="checkbox" /></label>
        <label>No
        <input type="checkbox" name="pubno" value="checkbox" />
        </label></td>
    </tr>
    <tr>
      <td><input name="submit" type="submit" onclick="MM_validateForm('first','','R','last','','R','email','','RisEmail','orgaddress','','R','orgcity','','R','orgstate','','R','orgzip','','R','tele','','R','password','','R','confirmpassword','','R');return document.MM_returnValue" value="Register" />
<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="redirect" value="http://herndonalliance.org/HA2/HA3/AHAdata/partnersThanks.php" />
      Return <a href="../../index.php">Home </a></td>
    </tr>
  </table>
  </form>
  <p> </p>

</div>
<!--end content--> 
	<!-- Begin Clear For code use Do Not add content here!-->
	  <div id="clear"> <p> </p> </div>
	<!-- End Clear -->
<!-- Start Footer-->
<div id="footer">
<!-- Insert footer -->
<?php 
include('../../lbi/footer.lbi');
?>
</div>
<!-- End Footer -->
<!-- End main -->
</div>
<!-- End Body -->
</body>
<!--bye bye Hafoc Yates hafoc.org 2007 -->
</html>

 

Link to comment
Share on other sites

Much better!

 

Try this for your connect file:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_regconnection = "db47int.dotsterhost.com";
$database_regconnection = "db100162_HAreg";
$username_regconnection = "u100162_herndon";
$password_regconnection = "zzz";
$regconnection = mysql_pconnect($hostname_regconnection, $username_regconnection, $password_regconnection) or trigger_error(mysql_error(),E_USER_ERROR);

$database_select_1 = "partners"; //the name of the table being used
$selectdb = mysql_select_db("$database_select_1");
if(!$selectdb)
{
   //If it can't select the table, report an error
	echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>';
	$str = mysql_error();
	echo $str;
}
?>

 

What happens?

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.