Re: Adding products from website form (not from admin)
Quote:
Originally Posted by
TesterServers
Hey dropbop, I just thought about something. If you have it set to send a "unique or random" id along, then depending on how you have the unique field setup, you'll need to be certain that it wouldn't generate a product id that already exists.
Kevin
Its actually very easy, i use the php time() which generates a unique 10 digit number every second (or maybe every millisecond, who knows).
Code:
$model = time();
$query = "INSERT INTO zen_products (products_id, products_model) VALUES ('$model', '$model')";
mysql_query($query) or die(mysql_error());
mysql_close();
?>
So, to give an example: at 21:44 I submitted and form and got the product_id and products_model of '1301949811'
at 20:45 i got 1301946292
at 20:33 i got 1301945598
etc etc
As you can see here, to make things easier on myself, I also use the time() to generate my model numbers which is very handy and keeps things nice and neat for me.
What I have also just added to the whole thing is a downloadable txt file which is also named by and saved to a downloads folder which contain the full details of the quote request (not just the few basics you see on the zen site).
So now when a form is submitted, it will 1) create a product, 2)create the attribute (download), 3) create the download txt file for the attribute. 4)Send an email to the person who filled in the form with the details they submitted & 4) send me an email with the details.
Ive never done anything like this before, mainly just templates so this is all a first for me. But I can tell you, I have learned so much and I dont think I have ever been on as many php forums in my life trying to figure stuff out. lol Well worth hte effort though.
DB
Re: Adding products from website form (not from admin)
Quote:
Originally Posted by
gjh42
I wonder if this would be vulnerable to SQL injection or other hacks... If you used some of the built-in Zen Cart db functions, you could probably be sure of safety.
The way it is now, it would be.
Once I get it working the way i want, then I can start adding any safety features... probably a good captcha should do the trick and place a database connect file in a different location.
I will say tho to anyone who does try this out (when i get it up here) not to overlook security one bit. It doesnt take alot of effort to make things secure, and there are plenty of different methods of doing it. So be warned, use it or loose it sister!! :lamo:
Re: Adding products from website form (not from admin)
Quote:
Originally Posted by
TesterServers
I can see this being very useful as it has been constructed so far by you. If I can help out in any way, just me know and I'll see what I can do. But I definitely want to check it out once you're completed your starting point.
Kevin
Give it a test if you like :)
Form is on www.timberdecks.ie
Submit that, then go on over to www.timberdecks.ie/trades/ (remember what 'county' you choose on the form because it will also be the category its in on zen)
If you want to properly see how it works, choose the product named the same as yours (will be in the email you get after submitting the form), purchase it, then open the download from the order history page in my account.
I have the cheque payment method active for testing and is set to 'delivered' so download should be available straight after you complete checkout.
Re: Adding products from website form (not from admin)
Sorry i have not gotten back to this yet, been very busy, but will update soon :)
DB
Re: Adding products from website form (not from admin)
Sorry to anyone who was waiting on an update here about the above... I got side-tracked (very side-tracked)..
I have been working on the script again adding some protection against sql injection and the likes, and will hopefully have some sort of package put together which can be downloaded. The package will not be just the form on the home page as it was, it will more than likely be a full website package for starting your own quoting service.
The demo site is no longer available on the url I posted in previous posts, but I will upload the project to a new domain at some stage for people to play around with.
If anyone has any ideas they would like to see put into it, i would love to hear them and consider adding them to it where possible.
Cheers,
Droppy!