[Code info] For people wanting to make item mall.

Status
Not open for further replies.
Experienced Elementalist
Joined
Sep 11, 2006
Messages
291
Reaction score
10
Location
Canada
This is a how to make, This doesn't give all the code for it

To break it down its like this:

Elements
Id Name Method Action

You make a button which submits to buy.php
With a command to mysql that adds a new line to storage
table, and minuses from the character table the price of the item.
In buy.php it would have this as well as the user session to make sure

this person has an account(Person who clicks buy)
Then you'd need a variable when they login set
cookies for their session of course.
Then when this is done, You make a character choosing page.
Note(This could all be done with RoseCMS lite) and just add the following to the "?itemshop" part of Rose CMS
You just add a link to it in characters.php


<?php

If (!empty($_POST[‘formvar’]))

{

//User has submitted the form

//Do something to make sure data is clean, such as strip_tags()

//You should probably convert non-alphanumeric chars to hex or something... but u can do that yourself... this is only an example

strip_tags($_POST[‘formvar’]);



//Connect to MySQL, select DB

$conn = mysqli_connect ($host,$user,$pass);

mysqli_select_db($dbname);



//Generate SQL Query Statement

$sql = ‘INSERT INTO `storage` VALUES (“’ . $_POST['.$item.‘] . ’”)’;
$sql = ‘INSERT INTO `characters` donation (“’ . $_POST[‘.$price.‘] . ’”)’;
If ($res = mysql_query ( $sql ))

{

//Inserted!!!

echo “Alex has successfully submitted his information and stored it...”;

}



}

else

{

//User hasn’t submitted the form... take them back?

header(‘Location: characters.php’);

}

?>



Call this one itemmall.php(You'd add this to Elements Mall page)

<form action=”buy.php” method=”post”>
<img src="the-item-you-are-selling.gif">
<input type=”hidden” name=”This area needs variables/commands” />

<input type=”submit” value=”whatever is in hidden” />

</form>


Elements broken down:





Note to dyeprey: I used some of your forms as reference ;/
Gotta love firefox plugins.
 
Status
Not open for further replies.
Back