Getting input and changing variable?

Hi I am new to scripting and have a function in my .sh script file that outputs a html radio button form

weather_forecast_config()
{
	echo ""
echo "<html><head><title>Welcome</title></head>"
echo "<body>"
echo "<h2>Weather Forecast - Change City</h2>"
echo "<form name="input" action="startPage.html" method="get">"
echo "<input type="radio" name="$cityconfig" value="$MUMBAI" >Mumbai<br>"
echo "<input type="radio" name="$cityconfig" value="$LONDON" >London"
echo "<input type="submit" value="Submit">"
echo "</form>"
echo "</body></html>"

if [ $cityconfig = "$MUMBAI" ]; then
               echo $WEATHERCONF ="204842"
               elif [ $cityconfig  = "$LONDON" ]; then
               echo $WEATHERCONF = "328328"
            fi
}

What I want the code to do is if the london radio button is selected and submitted this changes the $WEATHERCONF value to 328328, the $weatherconf is on another script whiich is output as startPage.html. The $weatherconf is in the code:

weather_forecast()
{
	

echo ""
echo "<html><head><title>Welcome</title></head>"
echo "<body>"
echo "<h2>Weather Forecast</h2>"
 echo "<a href="http://www.accuweather.com/en/gb/leicester/le1-3/weather-forecast/$WEATHERCONF" class="aw-widget-legal">"
echo "</a><div id="awcc1384544545323" class="aw-widget-current"  data-locationkey="$WEATHERCONF" data-unit="c" data-language="en-gb" data-useip="false" data-uid="awcc1384544545323"></div><script type="text/javascript" src="http://oap.accuweather.com/launch.js"></script>"

echo "</body></html>"
}

any help would be appreciated thanks

Try assigning value to variable this way and see if this is what you are trying to do:

if [ $cityconfig = "$MUMBAI" ]; then
  WEATHERCONF="204842"
elif [ $cityconfig  = "$LONDON" ]; then
  WEATHERCONF="328328"
fi

Thanks but no luck i tried:

In my config.sh file

cityconfig=""
CitySelect="LONDON"



##### Functions
weather_forecast_config()
{

	echo "cityconf = $cityconfig"
echo "<html><head><title>Welcome</title></head>"
echo "<body>"
echo "<h2>Weather Forecast - Change City</h2>"
echo "<form name="input" action="startPage.html" method="get">"
echo "<input type="radio" name="$CitySelect" value="MUMBAI" >Mumbai<br>"
echo "<input type="radio" name="$CitySelect" value="LONDON" >London"
echo "<input type="submit" value="Submit">"
echo  "<input type="reset" value="Reset!"><br>"
echo "</form>"
echo "</body></html>"

if [ $CitySelect = "MUMBAI" ]; then
  cityconfig="204842"
  echo "cityconfig is mumbai? = $cityconfig"
elif [ $CitySelect  = "LONDON" ]; then
  cityconfig="328328"
  echo "cityconfig is london? = $cityconfig"
fi


}

the output echos a statement and shows that the if statement is working but its not changing based on the form inout but the initial value I set? Any Help with the html form have I got the name and value wrong?

thanks

Nothing is going to automatically change the value of $CitySelect for you, CGI doesn't work that way. When the user makes a GET query, the entire string appears in ${QUERY_STRING}, which you can process as you please, deriving the value from it instead of setting it to LONDON.

Your script makes HTML like this:

<body>
<h2>Weather Forecast - Change City</h2>
<form name="input" action="startPage.html" method="get">
<input type="radio" name="LONDON" value="MUMBAI" >Mumbai<br>
<input type="radio" name="LONDON" value="LONDON" >London
<input type="submit" value="Submit">
<input type="reset" value="Reset!"><br>
</form>
</body></html>

...which I seriously doubt is what you want.

I basically want to update the variable in another script in the config script and send the amended value on submit to change the city. Would you suggest a different method or would this way work.

Another newbie question - do i just echo out ${QUERY_STRING} as written to output the get value/how exactly can you process this?

Your other script has to process ${QUERY_STRING} and extract the variable from it. ${QUERY_STRING} will contain values like

VAR1=value1&VAR2=value2&VAR3=value3

just like you'd see appended to the end of the webpage.

I process it like this:

# Just an example/test, you should not set QUERY_STRING yourself
QUERY_STRING="a=b&c=d&g=h&i=j"

OLDIFS="$IFS"
IFS="&" # Split strings upon & instead of space
        set -- ${QUERY_STRING} # Set $1="a=b", $2="c=d", $3="g=h", $4="i=j"
        while [ "$#" -ne 0 ] # Loop until we're all out of $1 $2 $3 ...
        do
                IFS="=" read NAME VAL <<EOF
${1}
EOF
                IFS="=" read CGI_"$NAME" VAL <<EOF
${1}
EOF
                shift # Get rid of $1 so $1="c=d", $2="g=h", ...
        done

IFS="$OLDIFS" # Return to default splitting behavior

echo ${CGI_a}
echo ${CGI_c}
echo ${CGI_g}

You will end up with variables like CGI_a, CGI_c, CGI_g, and so forth. The CGI_ prefix is so that web users can't accidentally (or worse, maliciously) change important, special variables like PATH in your script... This way if someone tries, all they'll set is CGI_PATH.

All the read junk is just a tricky way of setting random variable names without resorting to eval. This prevents malicious web users from feeding `rm -Rf ~/ into your code...