/    Sign up×
Community /Pin to ProfileBookmark

Quick IF this then that

hi i have this code and would it be possible in adding it to the “SHOW THE FORM HERE” bit in the below code :

[code=php]<?php
ob_start();
// allows you to use cookies
include(“config.php”);
$profile = mysql_query(“SELECT * from users where username = ‘$logged[username]'”);
$profile = mysql_fetch_array($profile);
//gets the config page
if ($_POST[create]) {
// the above line checks to see if the html form has been submitted
$alliancename = $_POST[alliance];
//the above lines set variables with the user submitted information
if($alliancename==NULL) {
//checks to make sure no fields were left blank
echo “A field was left blank.”;
}else{
$checkname = mysql_query(“SELECT alliancename FROM users WHERE alliancename=’$alliancename'”);
$checkname= mysql_num_rows($checkname);
if ($checkname>0) {
// oops…someone has already got that name as there clan!
echo “The clan name is already in use”;
}else{
// noone is using that email or username! We continue…
$alliancename = htmlspecialchars($alliancename);

$update = mysql_query(“Update users set alliancename = ‘$alliancename’ where username = ‘$logged[username]'”)
or die(mysql_error());
// inserts the information into the database.
echo “You have created the alliance $alliancename <BR />”;
echo “Go<BR /><a href=”main.php”>Back to game</a><BR />”;
}
}
}
else
{
// the form has not been submitted…so now we display it.
echo (”
<center>
<form method=”POST”>
Your Clans Name: <input type=”text” size=”15″ maxlength=”25″ name=”alliance”><br />
<input name=”create” type=”submit” value=”Create”>
</form>
</center>
“);
}
?>[/code]

and whant it so the code above can be put in where the “SHOW THE FORM HERE” is below:

[code=php]if($logged[alliancename] != 0) {
// incorrect
echo “You are in the alliance $alliancename”;
}else{
// Correct
echo “SHOW THE FORM HERE”;
}[/code]

any help is so helpfull to me

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@mitchellauthorNov 26.2007 — i take it its a hard thing to do ?
Copy linkTweet thisAlerts:
@NogDogNov 26.2007 — Well, have you tried copy-and-pasting it into the place where you want it?
Copy linkTweet thisAlerts:
@mitchellauthorNov 26.2007 — yes, it comes up with errors, but it all works sepperate
Copy linkTweet thisAlerts:
@NogDogNov 26.2007 — It might be best to show us your modified code along with the exact error messages. (It's pretty tough for any of us to test it ourselves since we don't have any of the include files or the underlying database.)

PS: Some sort of consistent indenting of the code will both help you keep your sanity and encourage forum members to actually try to make sense of the code.
Copy linkTweet thisAlerts:
@mitchellauthorNov 26.2007 — well basicly the top code is all about a form to create a name for your feild called "alliancename" and the if statement i want on the page is so if its defalt 0 then show the form
×

Success!

Help @mitchell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...