Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Form in a box


angryquaker

Recommended Posts

I'm *this close* to finally having this SMS/txt message list thingy finished. I think. Shadow007 very graciously helped me along the way, and gave me some examples of how the information I want could be collected on the create_account and account_edit pages, then passed to the corresponding tables in the DB. I hacked together some code based on that, and would really like to get this all contained within an infobox. I have no idea how to get all this code in there and make it work.

 

Also, the error checking in the file isn't working, and I can't figure out why on that one, either. I've defined the filenames, added a check to the "form_check.js.php" file, dunno what I've missed. I want it to return an error message if anything other than 10 digits are placed in the "10-Digit Cell Number" field, and/or if a provider is not selected. See the thing in action at

 

http://www.utopiawellness.com/sms_infobox.php

 

And here's the code for it:

<?php

 require('includes/application_top.php'); //<-- I can prob'ly remove this once it's in a box, included in a column?
 require('provider_info.php');


$cell_phone = tep_db_prepare_input($HTTP_POST_VARS['cell_phone']);

if (strlen($cell_phone) != ENTRY_TELEPHONE_MIN_LENGTH) {
  $error = true;

  $messageStack->add('sms_infobox', ENTRY_CELLPHONE_NUMBER_ERROR);
}

if ($error == false) {
  $sql_data_array = array( 
						  'customers_cell_phone' => $_POST["cell_phone"],
						  'customers_cp_provider' => $_POST["cp_provider"]);
}						   

if(tep_not_null($_POST["cell_phone"]) && tep_not_null($_POST["cp_provider"]))
  {
	  $phplist_user_array = array(
								  "email" => $_POST["cell_phone"].'@'.$_POST["cp_provider"], 
								  "confirmed" => 1,
								  "entered" => date("Y-m-d H:i:s"),
								  "modified" => date("Y-m-d H:i:s"),
								  "uniqid" => md5(uniqid(mt_rand())),
								  "htmlemail" => 0,
								  "foreignkey" => $customer_id
								  );
	  tep_db_perform("phplist_user_user", $phplist_user_array);
	  $phplist_user_id = tep_db_insert_id();

	  $phplist_userlist_array = array(
										"userid" => $phplist_user_id,
										"listid" => 2, //Change this to your desired list number in phplist
										"entered" => date("Y-m-d H:i:s"),
										);
	  tep_db_perform("phplist_listuser", $phplist_userlist_array);
		tep_redirect(tep_href_link(FILENAME_CREATE_SMSLIST_SUCCESS, '', 'SSL'));

  }   


?>

<?php echo tep_draw_form('sms_infobox', tep_href_link(FILENAME_CREATE_SMSLIST, '', 'SSL'), 'post', 'onSubmit="return check_form(sms_infobox);"') . tep_draw_hidden_field('action', 'process'); ?>
 <table width="200px" border="0" cellspacing="0" cellpadding="0">
		 <tr>
<td align="center" class="smallText">Sign up to receive updates, special sales, etc, via SMS/text message directly to your cell phone!</td>
		 </tr>
		 <tr>
			<td align="center" class="smallText">10-Digit Cell Number:</td>
		 </tr>
		 <tr>
			<td align="center" class="smallText"><?php echo tep_draw_input_field('cell_phone'); ?></td>
		</tr>
		<tr>
<td align="center" class="smallText"> *numbers only, no spaces or dashes</td>
		  </tr>
		  <tr>
			<td align="center" class="smallText">Service Provider:</td>
		  </tr>
		  <tr>
  	<td align="center" class="smallText"><?php echo tep_draw_pull_down_menu('cp_provider',$provider_array); ?></td>
		  </tr>
		  <tr>
 <td width="100%"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		  </tr>
		  <tr>
<td align="center"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
		  </tr>
 </table>

 

As it stands, you can put in 10 digits, 15 digits, 1 digit, or whatever, and still get to the success page (and make a new entry to the DB). Any other tips or suggestions on making this better, more efficient, more correct, would also be appreciated. Thanks in advance to whomever would care to help me finish up here. These 40-odd lines of code represent my greatest lifetime achievement in php so far. LOL Not saying much, is it? <_<

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

Anyone? Please? I am no closer to having it right than I was last night. I've been over and over the w3schools php tutorials, but it seems like they take for granted that you already know the basics of coding languages. I don't. I wouldn't know an array from a function if they both came up and bit me. Well, it may not be quite that bad, but any success I have is usually from blindly trying something, and making umpteen mistakes until I finally stumble into something that works. Most times, by the time I get it right, I've forgotten what steps I took to get there. LOL

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

You havent closed your form, so no data submited.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Thanks, Sam. I added the close form tag, and still get the same result. I was able to input "123" in the number field, nothing in the drop-down, and still got the success page. I'd like it to validate that there are 10 digits in the input field, and something selected in the drop-down. In my limited knowledge, I'm thinking the line:

 

if(tep_not_null($_POST["cell_phone"]) && tep_not_null($_POST["cp_provider"]))

 

is where that's checked, is it not? Wouldn't surprise me at all if I'm wrong.

 

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

Looking at your comment in the code, its a box, but are you trying it standalone for now?, if so it needs a html header & body tags.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

That's correct, I am trying to stuff it into an infobox right now. For testing, I'd been using it as a stand-alone page. If my infobox hack works, I'll let you know. If not, I'll add those tags to make it a proper html page and see what happens.

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

My infobox hack didn't work. LOL I'll keep trying on that. Meanwhile, I added tags to make it a whole stand-alone page, still getting the same results. I thought I'd "View Source" to see if I could glean some insight, this is what the browser is seeing:

 

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="LTR" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Utopia Wellness e-Store</title>
<base href="https://www.utopiawellness.com/">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
var form = "";
var submitted = false;
var error = false;
var error_message = "";

function check_input(field_name, field_size, message) {
 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
var field_value = form.elements[field_name].value;

if (field_value.length < field_size) {
  error_message = error_message + "* " + message + "\n";
  error = true;
}
 }
}

function check_radio(field_name, message) {
 var isChecked = false;

 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
var radio = form.elements[field_name];

for (var i=0; i<radio.length; i++) {
  if (radio[i].checked == true) {
	isChecked = true;
	break;
  }
}

if (isChecked == false) {
  error_message = error_message + "* " + message + "\n";
  error = true;
}
 }
}

function check_select(field_name, field_default, message) {
 if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
var field_value = form.elements[field_name].value;

if (field_value == field_default) {
  error_message = error_message + "* " + message + "\n";
  error = true;
}
 }
}

function check_password(field_name_1, field_name_2, field_size, message_1, message_2) {
 if (form.elements[field_name_1] && (form.elements[field_name_1].type != "hidden")) {
var password = form.elements[field_name_1].value;
var confirmation = form.elements[field_name_2].value;

if (password.length < field_size) {
  error_message = error_message + "* " + message_1 + "\n";
  error = true;
} else if (password != confirmation) {
  error_message = error_message + "* " + message_2 + "\n";
  error = true;
}
 }
}

function check_password_new(field_name_1, field_name_2, field_name_3, field_size, message_1, message_2, message_3) {
 if (form.elements[field_name_1] && (form.elements[field_name_1].type != "hidden")) {
var password_current = form.elements[field_name_1].value;
var password_new = form.elements[field_name_2].value;
var password_confirmation = form.elements[field_name_3].value;

if (password_current.length < field_size) {
  error_message = error_message + "* " + message_1 + "\n";
  error = true;
} else if (password_new.length < field_size) {
  error_message = error_message + "* " + message_2 + "\n";
  error = true;
} else if (password_new != password_confirmation) {
  error_message = error_message + "* " + message_3 + "\n";
  error = true;
}
 }
}

function check_form(form_name) {
 if (submitted == true) {
alert("This form has already been submitted. Please press Ok and wait for this process to be completed.");
return false;
 }

 error = false;
 form = form_name;
 error_message = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n";


 check_input("firstname", 2, "Your First Name must contain a minimum of 2 characters.");
 check_input("lastname", 2, "Your Last Name must contain a minimum of 2 characters.");


 check_input("email_address", 6, "Your E-Mail Address must contain a minimum of 6 characters.");
 check_input("street_address", 5, "Your Street Address must contain a minimum of 5 characters.");
 check_input("postcode", 5, "Your Zip Code must contain a minimum of 5 characters.");
 check_input("city", 3, "Your City must contain a minimum of 3 characters.");

 check_input("state", 2, "Your State must contain a minimum of 2 characters.");

 check_select("country", "", "You must select a country from the Countries pull down menu.");

 check_input("telephone", 10, "Your Telephone Number must contain a minimum of 10 characters.");
 check_input("cellphone", 10, "Your Cellphone Number must be exactly  10 characters, including area code.");

 check_password("password", "confirmation", 7, "Your Password must contain a minimum of 7 characters.", "The Password Confirmation must match your Password.");
 check_password_new("password_current", "password_new", "password_confirmation", 7, "Your Password must contain a minimum of 7 characters.", "Your new Password must contain a minimum of 7 characters.", "The Password Confirmation must match your new Password.");

 if (error == true) {
alert(error_message);
return false;
 } else {
submitted = true;
return true;
 }
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->

<form name="sms_infobox" action="https://www.utopiawellness.com/sms_infobox.php" method="post" onSubmit="return check_form(sms_infobox);"><input type="hidden" name="action" value="process">	  <table width="200px" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td align="center" class="smallText">Sign up to receive updates, special sales, etc, via SMS/text message directly to your cell phone!</td>
		  </tr>
		  <tr>
			<td align="center" class="smallText">10-Digit Cell Number:</td>
		  </tr>
		  <tr>
			<td align="center" class="smallText"><input type="text" name="cell_phone"></td>
		  </tr>
		  <tr>
			<td align="center" class="smallText"> *numbers only, no spaces or dashes</td>
		  </tr>
		  <tr>
			<td align="center" class="smallText">Service Provider:</td>
		  </tr>
		  <tr>
  				<td align="center" class="smallText"><select name="cp_provider"><option value="select" SELECTED>-select-</option><option value="message.alltel.com">Alltel</option><option value="txt.att.net">AT&T</option><option value="myboostmobile.com">Boost</option><option value="gocbw.com">Cincinnati Bell</option><option value="mobile.mycingular.com">Cingular</option><option value="mobile.celloneusa.com">Cellular One</option><option value="mms.mycricket.com">Cricket</option><option value="messaging.nextel.com">Nextel</option><option value="messaging.sprintpcs.com">Sprint PCS</option><option value="tmomail.net">T-Mobile</option><option value="email.uscc.net">US Cellular</option><option value="vtext.com">Verizon</option><option value="vmobl.com">Virgin</option><option value="other">Other</option></select></td>
		  </tr>
		  <tr>
			<td width="100%"><img src="images/pixel_trans.gif" border="0" alt="" width="1" height="10"></td>
		  </tr>
		  <tr>
			<td align="center"><input type="image" src="includes/languages/english/images/buttons/button_continue.gif" border="0" alt="Continue" title=" Continue "></td>
		  </tr>
  </table></form>
</body></html>

 

If that helps any. It sure doesn't shed any light for me. I'm as lost as I've ever been. heheheh

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

Anyone care to help me get this thing in an infobox? I have no idea how I'd add all that code and have it work, so I've tried several things like:

 

$info_box_contents[] = array('text' => '(sms_infobox.php)'); <-- shows "sms_infobox.php" in a box

 

$info_box_contents[] = array('text' => FILENAME_SMSBOX; <-- same

 

$info_box_contents[] = array('text' => 'include(sms_infobox.php)'); <-- same, except with the include/ path before the filename

 

I also tried just pasting all the code in between the ' ... '; with and without parentheses enclosing it, and of course, no luck with that. And, I tried defining the code as a variable (I think) as I'd seen in another infobox add-on, such as:

 

$content='my code here'

 

$info_box_contents[] = array('text' => $content);

 

And that didn't do it, either.

 

Is there some other type of array that I can specify if the array isn't just plain text? Like array('code' => 'my code here'); ?

 

I can keep slogging away on the error checking part, I'd just like to see this showing up in an infobox. Thanks!

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

I'm still plugging away at this, and still failing. :lol: LOL Although I did learn a new function, it doesn't do what I'd hoped it would. After searching the forums (again) for others trying to include various things in an infobox, I came across the following technique to include the contents of a file as a string:

 

<!-- smsbox //-->
	  <tr>
		<td>
<?php
//  $info_box_contents = array();
//  $info_box_contents[] = array('align' => 'center', 'text' => BOX_HEADING_PAGES);
//  new infoBoxHeading($info_box_contents, false, false);

 $sms_infobox = file_get_contents(FILENAME_SMSINFOBOX);

 $info_box_contents = array();

 $info_box_contents[] = array('text' => $sms_infobox);

 new infoBox($info_box_contents);
?>
		</td>
	  </tr>

<!-- smsbox_eof //-->

 

However, that basically just writes the contents of my php file into the infobox, as text. Is there a method I could use to have the php actually executed, rather than displayed as plain text? I don't even know if I'm using the correct terminology to explain this, "executing" the php is when the browser "runs" the file, and displays the desired output, right? :blush:

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

If you look at the categories file in admin, the section near the end deals with editing categories, where it places all the form stuff in a infobox, study thaty & you should see your way.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

I thought maybe just skipping the infoBox thing altogether, and calling the original php file as an include in column_left might work, so I tried that. It works, but I'm having trouble formatting it to maintain the appearance of an infoBox. If I put it inside a table, that table wants to expand to 100% of the page width, regardless of whether I define the width as 200px. If I try to put it in a div, the div appears at the top of column_left, and doesn't contain the box as I'd like it to. If I try to contain it in a <tr> I get nothing, and in a <td> I get a teeny little empty box above the area where my form is. Being able to put this thing in an infoBox would solve these problems, but if anyone has suggestions as to how I might just make it LOOK like an infoBox, I'd settle for that. Anyone?

 

Namasté,

Russ

 

See it ---> In the left column, looking different from the other infoboxes

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

Thanks, Sam, we were typing at the same time. I'll have a look in the file you suggested, and see what I can come up with.

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

For the love of all that's good and holy, could someone take a look at this for me? I followed Sam's advice, looked into the admin/categories.php file, and tried to glean some insight. Being ignorant as I am, here's what I came up with:

 

  <tr>
<td>
<?php	 
$contents = array('form' => tep_draw_form('sms_infobox', tep_href_link(FILENAME_CREATE_SMSLIST, '', 'SSL'), 'post', 'onSubmit="return check_form(sms_infobox);"') . tep_draw_hidden_field('action', 'process'));
$contents = array('text' => '<tr><td align="center" class="smallText">Sign up to receive updates, special sales, etc, via SMS/text message directly to your cell phone!</td></tr>;
						 <tr><td align="center" class="smallText"><b>10-Digit Cell Number:</b></td></tr>');
$contents = array('form' =>	tep_draw_input_field('cell_phone', 'ex: 2145551234', 'size="15" maxlength="10"')); 
$contents = array('text' => '<tr><td align="center" class="smallText"><b>Service Provider:</b></td></tr>');
$contents = array('form' => tep_draw_pull_down_menu('cp_provider',$provider_array));
$contents = array('form' => tep_image_submit('button_sign_up.gif', 'Sign Up!')); 
echo '</form>';

 $info_box_contents = array();

 $info_box_contents[] = array('text' => $contents);

 new infoBox($info_box_contents);

?>
</td>
 </tr>

 

It's lined up better, and looks prettier in Notepad++, but I think we can get the idea. :rolleyes: At this point, I actually have an infoBox showing up where I want it. Trouble is, the only thing in the box is "$contents" or "Array" and nothing else (depending on whether I enclose the last $contents thingy in quotes or parentheses). Somebody throw me a rope, or pour me a stiff drink, or SOMEthing!! I'm lost! I'm still including the error checking stuff above this chunk of code, and that part shows up in "view source," but the only thing showing where the $contents should be is a couple spacers. I am totally befuddled here, but at the same time, fairly amazed that I was able to even get it this far. Thanks to Sam for that, but man, am I out of my league here! LOL

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

I don't think you`ve looked close enough.

 

1st point:

 

you are including table elements within the infobox, the infobox is a table, so you could easily mess it up that way, try to use <br> instead, or have complete tables.

 

2nd you may not realise it, but you are creating a multi dimentioned array, probably the cause of you current display.

 

instead of:

 

$info_box_contents = array();

 $info_box_contents[] = array('text' => $contents);

 new infoBox($info_box_contents);

 

try:

 

$heading[] = array('text' => '<b>' . 'My box heading'. '</b>');

new infoBoxHeading($heading, false, false);
new infoBox($contents);

 

 

I`ve not tested, so no guarantees.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

You know what cracks me up? All the times I've figured out what I'm asking about, while composing a new post about the question. It just happened again, and I'm chuckling to myself again. The form thingy in the box is now working.

 

The error checking portion, however, is still NOT working.

 

Anyone care to share ideas? Sam is doing an excellent job helping, and making me figure stuff out for myself, I kinda like that, but I wouldn't mind at all if someone just jumped in and said, "Oh, yeah, do this, and it will work." :rolleyes: Either way, let's go!

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

Good morning, friends and neighbors. I'm back at it, hoping to have this error checking functionality, uh...functional today. In my special infobox, from what I can see, this part:

 

  require('provider_info.php');
 require('includes/form_check.js.php'); 

$cell_phone = tep_db_prepare_input($HTTP_POST_VARS['cell_phone']);

  if (strlen($cell_phone) != ENTRY_TELEPHONE_MIN_LENGTH) {
  $error = true;

  $messageStack->add('sms_infobox', ENTRY_CELLPHONE_NUMBER_ERROR);
}

if ($error == false) {
  $sql_data_array = array(

 

should be checking the input for the "cell_phone" field. If I understand correctly, the "if(strlen($cell_phone) !=" part checks the input against the min length for phone number, which I've set to 10. "!=" means "is not equal to," right? Or should I put "<>" in there instead? And again, if I am understanding this (which is highly suspect at this point), the "$messageStack->add" line should return an error message if $error = true, right? And then, if this error is not detected, it should continue to go ahead with the script, right?

 

Also notice that I've included (or required, as it were) the form_check file, and later down in my file, the form is calling form_check to check for errors:

 

(tep_draw_form('sms_infobox', tep_href_link(FILENAME_CREATE_SMSLIST, '', 'SSL'), 'post', 'onSubmit="return check_form(sms_infobox);"') . tep_draw_hidden_field('action', 'process')));

 

Right? Or do I need to change the check_form parameter to check_input, or what? Looking over it again, I see that check_form checks to see if the form has been submitted already, where check_input is what actually checks the fields. So should I be doing something more like this?

 

'onSubmit="return check_input(cell_phone);"'

 

OR...is there a conflict in using these two methods on the same form? I'm confused by the whole thing, honestly.

 

Finally, if I want to check the pull-down menu field, would it be best to add a definition to the form_check file for that, and how would I add that to the 'onSubmit' parameters? Or am I correct in thinking that this line:

 

	if(tep_not_null($_POST["cell_phone"]) && tep_not_null($_POST["cp_provider"]))

 

is checking to make sure there's something selected in that pull-down (cp_provider)? Is that what "tep_not_null" means? Oy vay. It's not even 10am yet, and I'm all discombobulated already.

 

Namasté,

Russ

 

EDIT - I tried to use colors in the "code" boxes, it didn't work.

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

I tried changing the != in my file to <>, same result. I changed the 'onSubmit="return check_form(sms_info)"' to check_input, no luck, and tried changing (sms_info) to (cell_phone), with no success. I don't know what else to try. Any suggestions? Pretty please?

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

How about now, anyone on the evening shift care to impart some wisdom? I'm still stuck on this error-checking thing.

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

OK. No, I still haven't sorted out this error-checking thing. Sometimes, I find it helpful to move on from a problem, let it stew around sub-consciously for a while, then come back to it. With this particular issue, either that will prove effective, or I'll keep asking and trying until I work it out.

 

Now, I've got a new thing I'd like to do, but I'm having trouble with it, too. I'm trying to use the tep_mail function to send a confirmation message when someone uses the form to subscribe to my list. Just a little "Hi, thanks for signing up, we gotcha" kinda thing. I looked into the tep_mail thing, and this is what I've come up with:

 

<?php 
[...bunch of other code...]

$name = 'SMS Friend';
$email = tep_db_select("phplist_user_user", "email");
$subject = 'Welcome!';
$text = 'You are now subscribed to the Utopia Wellness SMS Message list. Thanks!';
$sender_name = 'Utopia Wellness';
$sender_address = 'smslist@mydomain.com';

	  tep_mail($name, $email, $subject, $text, $sender_name, $sender_address);
?>

 

I've tried a couple different things on the tep_db_select() line, but nothing I've tried seems to be working. I'm not getting error messages as it is now, just not getting any mail sent to the intended recipient. I think I have the tep_mail() line right, it's just the part where the $email variable is being set that's not doing what I want. I've tried this on the page where the email info is collected and written to the DB (after said writing has occurred, right before the redirect), and also tried adding it to the "success" page, where the user is sent upon completing the subscription form. Neither instance gives the intended results. A little help, please?

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

OK, so I'm up to having this now:

 

$sql = "SELECT email FROM" .' '. 'phplist_user_user';		  
$name = 'SMS Friend';
$email = tep_db_query($sql);
$subject = 'Welcome!';
$text = 'You are now subscribed to the Utopia Wellness SMS Message list. Thanks!';
$sender_name = 'Utopia Wellness';
$sender_address = 'smslist@mydomain.com';

		tep_mail($name, $email, $subject, $text, $sender_name, $sender_address);

 

And it's not returning any errors, but I'm still not getting any messages to my test address. And thinking about it now, it seems that the above 'SELECT email FROM' statement, if the script were working properly, would send a message to every email address in that table. No? How would I tell it to only select the LAST address added to the table? Or moreover, how can I make this $email get the right address, and actually get the tep_mail function to send a message?! I'm getting frustrated! LOL :blush:

 

Namasté,

Russ

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

A little deconstruction:

 

$sql = "SELECT email FROM" .' '. 'phplist_user_user';

 

is your sql query

 

$email = tep_db_query($sql);

 

means apply the given query and place the results array in $email

 

tep_mail($name, $email, $subject, $text, $sender_name, $sender_address);

 

so that means send an email to array (havent you been there before?)

 

instead of $email select your data from the array with $email['email']

 

I`ve not looked through the rest so they may be more to find.

 

This is a very helpful resource: http://oscommerce-reference.swisscart.com/...ions/index.html

 

NB. If you post the whole of your current code instead of little snippits poeple are more likely to see your errors.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Thanks, Sam. Thanks for all your help thus far, for any help you may offer me in the future, and for the link to that reference site. Thanks, too, for not just telling me to shut up and learn to code. I'm trying, and I appreciate all the help I receive here.

 

The snippet of code I included last time is just the part I'm working on. The rest of the file is the standard create_account_success.php file, modified to be my new create_smslist_success.php. The only significant modification is the portion I've added to send an email to the signer-upper. That's why I only posted that snippet.

 

So then, after thinking about it, I've come to the conclusion that I should, indeed, have the confirmation email sent by the "success" page, so if I ever get the error-checking working, it won't send a confirmation if someone submits the page without the proper information filled in. Only when they get the "success" page would the confirm be sent. For reference, I'll post the contents of both those files here, now.

 

create_smslist_success.php:

<?php
/*
 $Id: create_smslist_success.php 1739 2007-12-20 00:52:16Z hpdl $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_SMSLIST_SUCCESS);

 $breadcrumb->add(NAVBAR_TITLE_1);
 $breadcrumb->add(NAVBAR_TITLE_2);

 if (sizeof($navigation->snapshot) > 0) {
$origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);
$navigation->clear_snapshot();
 } else {
$origin_href = tep_href_link(FILENAME_DEFAULT);
 }

// start smslist mod
$sql = "SELECT email FROM" .' '. 'phplist_user_user';		  
$name = 'SMS Friend';
$email = tep_db_query($sql);
$subject = 'Welcome!';
$text = 'You are now subscribed to the Utopia Wellness SMS Message list. Thanks!';
$sender_name = 'Utopia Wellness';
$sender_address = 'smslist@mydomain.com';

		tep_mail($name, $email['email'], $subject, $text, $sender_name, $sender_address);
// end smslist mod

?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
<td width="<?php echo BOX_WIDTH_LEFT; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH_LEFT; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td><?php echo tep_image(DIR_WS_IMAGES . 'table_background_man_on_board.gif', HEADING_TITLE); ?></td>
		<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td class="pageHeading" align="center"><?php echo HEADING_TITLE; ?></td>
		  </tr>
		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
		  </tr>
		  <tr>
			<td class="main"><?php echo TEXT_SMSACCOUNT_CREATED; ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td align="right"><?php echo '<a href="' . $origin_href . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
</table></td>
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

and the sms_infobox.php file:

<?php

// sms_infobox bof

 require('provider_info.php');
 require('includes/form_check.js.php'); 

$cell_phone = tep_db_prepare_input($HTTP_POST_VARS['cell_phone']);

if (strlen($cell_phone) <> ENTRY_TELEPHONE_MIN_LENGTH) {
  $error = true;

  $messageStack->add('sms_infobox', ENTRY_CELLPHONE_NUMBER_ERROR);
}

if ($error == false) {
  $sql_data_array = array( 
						  'customers_cell_phone' => $_POST["cell_phone"],
						  'customers_cp_provider' => $_POST["cp_provider"]);
}						   

if(tep_not_null($_POST["cell_phone"]) && tep_not_null($_POST["cp_provider"]))
  {
	  $phplist_user_array = array(
								  "email" => $_POST["cell_phone"].'@'.$_POST["cp_provider"], 
								  "confirmed" => 1,
								  "entered" => date("Y-m-d H:i:s"),
								  "modified" => date("Y-m-d H:i:s"),
								  "uniqid" => md5(uniqid(mt_rand())),
								  "htmlemail" => 0,
								  "foreignkey" => $customer_id
								  );
	  tep_db_perform("phplist_user_user", $phplist_user_array);
	  $phplist_user_id = tep_db_insert_id();

	  $phplist_userlist_array = array(
										"userid" => $phplist_user_id,
										"listid" => 2, //Change this to your desired list number in phplist
										"entered" => date("Y-m-d H:i:s"),
										);
	  tep_db_perform("phplist_listuser", $phplist_userlist_array);

	  tep_redirect(tep_href_link(FILENAME_CREATE_SMSLIST_SUCCESS, '', 'SSL'));

  }   


?>
 <tr>
<td>
<?php	 
$contents[] = array('align' => 'center', 'text' => (tep_draw_form('sms_infobox', tep_href_link(FILENAME_CREATE_SMSLIST, '', 'SSL'), 'post', 'onSubmit="return check_input(cell_phone);"') . tep_draw_hidden_field('action', 'process')));
$contents[] = array('align' => 'center', 'text' => 'Subscribe to receive natural wellness tips, special sales, etc, via SMS/text message directly <br />to your cell phone!<br />' . '<a href="' . tep_href_link(FILENAME_SMS_INFO) . '">' . '(<i>...more info...</i>)' . '</a>' . '<br /><br /><b>10-Digit Cell Number:</b><br />');
$contents[] = array('align' => 'center', 'text' => (tep_draw_input_field('cell_phone', 'ex: 2145551234', 'size="15" maxlength="10"'))); 
$contents[] = array('align' => 'center', 'text' => '<b>Service Provider:</b>');
$contents[] = array('align' => 'center', 'text' => (tep_draw_pull_down_menu('cp_provider',$provider_array)));
$contents[] = array('align' => 'center', 'text' => (tep_image_submit('button_sign_up.gif', 'Sign Up!'))); 

$heading[] = array('text' => '<a href="'. tep_href_link(FILENAME_SMS_INFO) . '">' . BOX_HEADING_SMSLIST . '</a>');

new infoBoxHeading($heading, false, false);
new infoBox($contents);
echo '</form>';
?>
</td>
 </tr>	
<?php //sms_infobox eof ?>

 

In the success page, I need it to send an email to the user who signed up via sms_infobox, using the email address which is constructed and sent to the phplist_user_user table from the sms_infobox page. Can I pass the $email variable from the infobox page to the success page? (thinking "out loud" here, and remember, I'm completely in the dark on this stuff.)

 

In the infobox page, I need some validation or error checking to be working, so they don't get to the success page without selecting a provider, and having exactly 10 digits in the cell number text field.

 

http://www.utopiawellness.com <----- to try it out, view sources, and so forth.

 

I'm really not all that stupid, it probably just seems like it, because I don't know the basics of coding languages. I think I'd mentioned previously that I wouldn't know a multi-dimensional array if it came up and bit me. I barely understand what an array is, period. But I am learning, and I do appreciate all the help everyone has so graciously provided me here. Really.

 

Namasté,

Russ

 

PS - I honestly believe that we, as humans, are multi-dimensional beings, experiencing what we perceive as "reality" in the ways we do as a result of being spiritual entities trapped in physical bodies, with the limitations inherent to such. But that doesn't really help me understand multi-dimensional arrays, does it? Drat and blast.

One: people are not wearing enough hats. Two: matter is energy. In the universe, there are many energy fields which we cannot normally perceive. Some energies have a spiritual source which act upon a person's soul. However, this soul does not exist ab initio, as orthodox Christianity teaches. It has to be brought into existence by a process of guided self-observation. However, this is rarely achieved, owing to man's unique ability to be distracted from spiritual matters by everyday trivia.

Link to comment
Share on other sites

  • 10 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...